/* Use the ReadLine method directly to complete the reading of a row of data entered by the keyboard. ReadLine is a method in the character stream BufferedReader class. The Read method of keyboard input is the method in byte stream inputstream. byte-to-character. */import java.io.*;class Transstreamdemo {public static void main (string[] args) throws ioexception{/*// Gets the keyboard entry object InputStream in=system.in;//converts a byte stream object to a character stream object, using the transform stream. Inputstreamreaderinputstreamreader isr=new InputStreamReader (in);//In order to improve efficiency, the string is efficiently manipulated by buffer technology. Use Bufferedreaderbufferedreader br=new BufferedReader (ISR); *///Keyboard entry The most common wording: BufferedReader br=new BufferedReader (new InputStreamReader (system.in)); OutputStream out=system.out;outputstreamwriter osw=new OutputStreamWriter (out); BufferedWriter bw=new BufferedWriter (OSW); String Line=null;while ((Line=br.readline ())!=null) {if (Line.equals ("Over")) Break;//system.out.println ( Line.touppercase ()); Bw.write (Line.touppercase ()); Bw.newline (); Bw.flush ();} Bw.close ();}}
/* Keyboard input reads one line, output one line */import java.io.*;class keyinput {public static void main (string[] args) throws Ioexception{keyinput ();} public static void Keyinput () throws Ioexception{inputstream in=system.in; StringBuffer sb=new StringBuffer (); while (true) {char ch= (char) in.read (); if (ch== ' \ R ') continue;if (ch== ' \ n ') {String Str=sb.tostring (); if (Str.equals ("over")); System.out.println (Str.touppercase ()); Sb.delete (0,str.length ());//emptying Container}elsesb.append (CH);}}
Java Keyboard input data