-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReader.java
More file actions
30 lines (23 loc) · 745 Bytes
/
Reader.java
File metadata and controls
30 lines (23 loc) · 745 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
28
29
30
import java.io.Reader;
import java.io.FileReader;
class Main {
public static void main(String[] args) {
// Creates an array of character
char[] array = new char[100];
try {
// Creates a reader using the FileReader
Reader input = new FileReader("input.txt");
// Checks if reader is ready
System.out.println("Is there data in the stream? " + input.ready());
// Reads characters
input.read(array);
System.out.println("Data in the stream:");
System.out.println(array);
// Closes the reader
input.close();
}
catch (Exception e) {
e.getStackTrace();
}
}
}