Advertisement
deyanmalinov

1. Create, Read and Write in Files

Apr 12th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package DPM;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.FileReader;
  6. import java.io.IOException;
  7.  
  8. public class Main {
  9.         public static void main(String[] args) throws IOException {
  10.                 File file = new File(FILE_PATH);
  11.                 BufferedReader reader = new BufferedReader(new FileReader(file));
  12.                 String line;
  13.                 while ((line = reader.readLine()) != null){
  14.                         System.out.println(line);
  15.                 }
  16. //                while (true){
  17. //                        String line = reader.readLine();
  18. //                        if (line == null){
  19. //                                break;
  20. //                        }
  21. //
  22. //                        System.out.println(line);
  23. //              }
  24.  
  25.         }
  26.         private static final String FILE_PATH = "D://Coding/Java/Softuni/Java Fundamentals  2016/3. Java-Streams/users.txt";
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement