Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- public class FileTesterTry {
- public static void main(String[] args) {
- String fileName = "testFile.txt";
- try (
- FileReader fileReader = new FileReader(fileName);
- BufferedReader reader = new BufferedReader(fileReader);
- ) {
- String nextLine = null;
- int lines = 0;
- while ((nextLine = reader.readLine()) != null) {
- System.out.println(nextLine);
- lines++;
- }
- System.out.println("Ilość wierszy w pliku: " + lines);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement