Advertisement
polpoteu

JAVA Pliki kopiowanie

Jan 17th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. try {
  2. File file = new File("dane.txt");
  3. Scanner sc = new Scanner(file);
  4.  
  5. while (sc.hasNextLine()) {
  6.  
  7. String lin = sc.nextLine();
  8. System.out.println(lin);
  9. arr = lin.split("-");
  10.  
  11. if (arr[3].contains("wies") && Integer.parseInt(arr[1]) >= 2) {
  12. Double cena = Double.parseDouble(arr[2]);
  13. cena = cena * 0.85;
  14. //arr[2] = Double.toString(cena);
  15. out.writeUTF(arr[0]);
  16. out.writeInt(Integer.parseInt(arr[1]));
  17. out.writeDouble(cena);
  18. out.writeUTF(arr[3]);
  19.  
  20. }
  21. }
  22.  
  23. out.close();
  24. sc.close();
  25. } catch (FileNotFoundException e) {
  26. e.printStackTrace();
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement