package p11_pliki;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;

public class PonumerujLinie2 {

    public static void main(String[] args) {
        try(BufferedReader input = Files.newBufferedReader(Paths.get("pliki/pan_tadeusz.txt"));
            PrintWriter out = new PrintWriter("pliki/ponumerowany.txt")) {
            String linia;
            int nr = 0;
            while((linia = input.readLine()) != null) {
                out.printf("%6d:%s%n", ++nr, linia);
            }
            System.out.println("Łącznie wszystkich linii: " + nr);
        } catch(IOException e) {
            e.printStackTrace();
        }
    }

}
