Advertisement
dxvmxnd

Untitled

Oct 30th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public static int sizeRowFile(String path) {
  2. int sizeI;
  3. boolean isIncorrect;
  4. Scanner scanner = null;
  5. try {
  6. BufferedReader bufferedReader = new BufferedReader(new FileReader(path));
  7. } catch (FileNotFoundException e) {
  8. System.out.println("Ошибка открытия файла");
  9. }
  10.  
  11. sizeI = 0;
  12. System.out.println("Считывание размера строк......");
  13. do {
  14. isIncorrect = false;
  15. try {
  16. scanner = new Scanner(new File(path));
  17. sizeI = Integer.parseInt(bufferedReader.readLine());
  18. } catch (IOException e) {
  19. System.err.println("Ошибка при чтении файла!");
  20. isIncorrect = true;
  21. }
  22. } while (isIncorrect);
  23. scanner.close();
  24.  
  25. return sizeI;
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement