forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaInputStreamText.java
More file actions
27 lines (20 loc) · 871 Bytes
/
JavaInputStreamText.java
File metadata and controls
27 lines (20 loc) · 871 Bytes
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
package com.zetcode;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
// InputStream is a source for reading data. A stream
// can represent various kinds of sources, including disk files, devices, other programs, and memory arrays.
public class JavaInputStreamText {
public static void main(String[] args) throws IOException {
String fileName = "src/resources/thermopylae.txt";
try (InputStream fis = new FileInputStream(fileName);
InputStreamReader isr = new InputStreamReader(fis,
StandardCharsets.UTF_8);
BufferedReader br = new BufferedReader(isr)) {
br.lines().forEach(line -> System.out.println(line));
}
}
}