inputstreamtest.java

来自「java I/0流的代码程序」· Java 代码 · 共 28 行

JAVA
28
字号
import java.io.*;

public class InputStreamTest
{
    public static void main(String[] args)
    {
        int b;
        byte buffer[]=new byte[2500];
        try
        {
            File f=new File("C:\\java测试及练习\\","InputStreamTest.java");
            FileInputStream file=new FileInputStream(f);
            b=file.read(buffer,0,2500);
            try
            {
                String str=new String(buffer,0,b,"Default");
                System.out.println(str);
            }
            catch(UnsupportedEncodingException e)
            {System.out.println("the encoding was not found:"+e);}
        }
        catch(IOException e)
        {System.out.println("File read Error");}


    }
}

⌨️ 快捷键说明

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