inout.java

来自「JAVA 2应用开发指南」· Java 代码 · 共 27 行

JAVA
27
字号
//InOut.Java
import java.io.*; 
public class InOut {
    public static void main(String[] args) { 
        echo(System.in); 
    }
    public static void echo(InputStream in) { 
        try { 
            while (true) { 
                int n = in.available(); 
                if (n > 0) {
                    byte[ ] b = new byte[n];
                    int result = in.read(b);
                    if (result ==-1) {
                        break;
                    }
                    String s = new String(b);
                    System.out.print(s); 
                }
             } 
        }
        catch (IOException e) { 
            System.err.println(e); 
        }
    }
}

⌨️ 快捷键说明

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