Monthly Archives: November 2008

Java Console and File Input/Output Cheat Sheet

Console OutputSystem.out.print(“Hello “);System.out.println(“world”);Console InputBufferedReader in = new BufferedReader(new InputStreamReader(System.in));String text = in.readLine();File OutputPrintWriter out = new PrintWriter(new FileWriter(“K:locationoutputfile.txt”)));out.print(“Hello “);out.println(“world”);out.close();File InputBufferedReader in = new BufferedReader(new FileReader(“K:locationinputfile.txt”));String text = in.readLine();in.close();Converting input dataString text = in.readLine();int x = Integer.parseInt(text);double y = Double.parseDouble(text);Reading until EOFwhile (in.ready()) { text = in.readLine(); System.out.println(text);}Pulling apart delimited items on a lineString text = […]

read more