forked from yankeexe/JavaPracticeNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByteStream.java
More file actions
31 lines (29 loc) · 807 Bytes
/
ByteStream.java
File metadata and controls
31 lines (29 loc) · 807 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
import java.io.*;
public class ByteStream
{
public static void main(String[] args) throws IOException{
FileInputStream in = null;
FileOutputStream out = null;
try{
in = new FileInputStream("input.txt");
out = new FileOutputStream("output.txt");
int c;
/**the byte is returned as an int in the range of 0 to 255.
* If no value is available and end of the stream has been reached
* then it returns -1.
*/
while ((c = in.read()) != -1)
{
out.write(c);
}
}
finally{
if(in != null){
in.close();
}
if(out != null){
out.close();
}
}
}
}