FileInputStream and FileOutputStream in Java - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Community

demo-image

FileInputStream and FileOutputStream in Java

Share This

Source code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.t4b.test;
import java.io.FileInputStream;
import java.io.IOException;
public class FileInputStreamTest {
public static void main(String[] args) {
FileInputStream fin;
try {
fin = new FileInputStream("test.txt");
int i = fin.read();
System.out.print((char) i);
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Source code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.t4b.test;
import java.io.FileOutputStream;
public class FileOutputStreamTest {
public static void main(String args[]) {
try {
FileOutputStream fout = new FileOutputStream("test.txt");
fout.write(65);
fout.write("Text".getBytes());
fout.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Happy Exploring!

Comment Using!!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.