Java tutorial
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void main(String[] args) { byte[] b = { 'h', 'e', 'l', 'l', 'o' }; try { OutputStream os = new FileOutputStream("test.txt"); InputStream is = new FileInputStream("test.txt"); os.write(b, 0, 3); for (int i = 0; i < 3; i++) { System.out.print((char) is.read()); } os.close(); is.close(); } catch (Exception ex) { ex.printStackTrace(); } } }