polpoteu

JAVA Pliki egz

Jan 31st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public class Main {
  2.  
  3. public static void main(String[] args) {
  4. // System.out.println(liczbaWystapien("ala ma kota", "a"));
  5.  
  6. File file = new File("student.txt");
  7.  
  8. try {
  9. FileOutputStream fout = new FileOutputStream("student3.txt");
  10. DataOutputStream out = new DataOutputStream(fout);
  11. Scanner sc = new Scanner(file);
  12.  
  13. while(sc.hasNext()){
  14. String[] student = sc.next().split(";");
  15. if(Integer.parseInt(student[2]) >= 3){
  16. out.writeUTF(student[0]);
  17. out.writeUTF(student[1]);
  18. out.writeUTF(student[2]);
  19.  
  20.  
  21. }
  22. }
  23. out.close();
  24. } catch (FileNotFoundException e) {
  25. e.printStackTrace();
  26. } catch (IOException e) {
  27. e.printStackTrace();
  28. }
  29. }
Add Comment
Please, Sign In to add comment