All pastes #940321 Raw Edit

InputStream

public text v1 · immutable
·published 2008-03-12 21:50 UTC
rendered paste body
import java.io.* ;


 public class Einsende2 {
    static BufferedReader In = new BufferedReader (new InputStreamReader (System.in)) ;
	    private static void test_io1()  throws IOException {
                int i=32;
                System.out.print("\nEingabe: ");
                i=System.in.read();
                In.readLine();
                System.out.println( (char)i );
                System.out.print("Eingabetechnik: System.in.read() OHNE Ausnahmebehandlung");
        }

        private static void test_io2() {
                int i=32;
                System.out.print("\n\nEingabe: ");
                try {
                        i=System.in.read();
                        In.readLine();
                } catch (IOException e) { System.out.println("Eingabefehler "+ e.getMessage()); }
                System.out.println( (char)i );
				System.out.print("Eingabetechnik: System.in.read() MIT Ausnahmebehandlung");
        }

        private static void test_io3()  throws IOException {
				String expr = new String();   
				System.out.print ("\n\nEingabe:  ");    
				expr = In.readLine();   
				System.out.println(expr) ;
				System.out.print("Eingabetechnik: BufferedReader");
		}

        public static void main(String[] args)  throws IOException {
                test_io1(); //Aufrufen der Methode test_io1() ,Sytem.in.read OHNE Ausnahmebehandlung
                test_io2(); //Aufrufen der Methode test_io2() ,System.in.read MIT Ausnahmebehandlung
                test_io3(); //Aufrufen der Methode test_io3() ,BufferedReader
        }
}