summaryrefslogtreecommitdiff
path: root/Java-Kompendium/kap14/2/Task2.java
blob: 2569c89a0e510544c22a158235fef117a44312f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.*;

public class Task2 {
    public static void main(String[] args) {
        FileInputStream fileReader = null;

        try {
            fileReader = new FileInputStream("../1/Notizen.txt");
        } catch (FileNotFoundException exception) {
            System.out.println(exception.getMessage());
            return;
        }
        var inputStream = new InputStreamReader(fileReader);
        var bufferedStream = new BufferedReader(inputStream);

        try {
            String input = bufferedStream.readLine();
            int counter = 1;

            while (input != null) {
                System.out.println(counter + ". " + input);

                ++counter;
                input = bufferedStream.readLine();
            }

            bufferedStream.close();
        } catch (IOException exception) {
            System.out.println(exception.getMessage());
        }
    }
}