Java tutorial
import java.io.BufferedWriter; import java.io.FileWriter; import java.io.InputStream; public class Main { public static void main(String[] args) throws Exception { InputStream in = System.in; BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt")); int letter; while ((letter = in.read()) != -1) { bw.write((char) letter); bw.flush(); } } }