j_echo1.java

来自「一个十分好的java基础学习的课件」· Java 代码 · 共 44 行

JAVA
44
字号
// ////////////////////////////////////////////////////////
// 
// J_Echo.java
// 

// ////////////////////////////////////////////////////////

import java.io.InputStream;
import java.io.IOException;

public class J_Echo1
{

    public static void mb_echo(InputStream in)
    {
        try
        {
            while (true) // Read input and echo
            {
                int n = in.available( ); 
                if (n > 0)
                {
                    byte[ ] b = new byte[n];
                    if (in.read(b) == -1)
                        return;
                    String s = new String(b);
                    System.out.print(s); 
                }
            } // End of loop: while
        }
        catch (IOException e)
        {
            System.err.println(e);
        } // End of try/catch structure
        System.out.println( ); 
    } // End of method: mb_echo

    public static void main(String args[])
    {
        mb_echo(System.in); 
    } // End of method: main

} // End of class: J_Echo

⌨️ 快捷键说明

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