Advertisement
dxvmxnd

Untitled

Dec 6th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public static String inputStrFromFile(String path) {
  2. boolean isNotCorrect;
  3. String str = "";
  4. System.out.println("Считывание строки...");
  5.  
  6. try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
  7. str = reader.readLine();
  8.  
  9. if (str.isEmpty()) {
  10. System.out.println("Ошибка ввода! Строка должна иметь хотя бы 1 символ! Введите строку с клавиатуры.");
  11. str = readStringFromConsole();
  12. }
  13. else {
  14. System.out.println("Строка для перекодирования: " + str);
  15. }
  16. } catch (IOException ioException) {
  17. isNotCorrect = true;
  18. }
  19.  
  20. return str;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement