ReverseConsoleInput.java Source code

Java tutorial

Introduction

Here is the source code for ReverseConsoleInput.java

Source

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();
    }
}