File size: 650 Bytes
c574d3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import java.io.*;
public class FileStreamTest {
public static void main(String args[]) {
try (OutputStream os = new FileOutputStream("test.txt"); InputStream is = new FileInputStream("test.txt");) {
byte[] bWrite = { 65, 90, 48, 57, 97, 122 };
for (int x = 0; x < bWrite.length; x++) {
os.write(bWrite[x]); // writes the bytes
}
int size = is.available();
for (int i = 0; i < size; i++) {
System.out.print((char) is.read() + " ");
}
} catch (IOException e) {
System.out.println("Exception");
}
}
}
|