-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowFile.java
More file actions
35 lines (30 loc) · 874 Bytes
/
Copy pathShowFile.java
File metadata and controls
35 lines (30 loc) · 874 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
31
32
33
34
35
import java.io.*;
class ShowFile {
public static void main (String args[]) {
int i;
FileInputStream fin;
if (args.length != 1) {
System.out.println("Usage : ShowFile FileName");
return;
}
try {
fin = new FileInputStream(args[0]);
} catch (FileNotFoundException e) {
System.out.println("Cannot open file as not found");
return;
}
try {
do {
i = (int) fin.readAllBytes();
if (i != -1) System.out.print((char) i);
} while (i != -1);
} catch (IOException e) {
System.out.println("Error Reading file.");
}
try {
fin.close();
} catch (IOException e) {
System.out.println("Error closing file.");
}
}
}