keyboardinput.java

来自「java是一种面向对象程序的语言,我这里介绍了有关java课件的许多事例,它能帮」· Java 代码 · 共 32 行

JAVA
32
字号
import java.io.*;

public class KeyboardInput {
 	public static void main (String args[]) {
	 	String s;
		 // Create a buffered reader to read
		 // each line from the keyboard.
		 InputStreamReader ir = new InputStreamReader(System.in);
		 BufferedReader in = new BufferedReader(ir);
                 
		 System.out.println("Type bye exit.");

		 try {
			 // Read each input line and echo it to the screen.
			 s = in..readLine();
              		 while ( s != null ) {
                            if(s.equals("bye")){
                                 break;
                            }else{
				 System.out.println("Read: " + s);
				 s = in.readLine();
                            }
			 }

			 // Close the buffered reader.
			 in.close();
		 } catch (IOException e) { // Catch any IO exceptions.
			 e.printStackTrace();
		 }
	 }
 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?