Java tutorial
import java.io.BufferedReader; import java.io.InputStreamReader; class ReverseConsoleInput { public static void main(String args[]) throws Exception { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); // Read and process lines from console String s; while ((s = br.readLine()) != null) { StringBuffer sb = new StringBuffer(s); sb.reverse(); System.out.println(sb); } isr.close(); } }