读书人

io 资料读取通用格式

发布时间: 2012-12-23 11:28:15 作者: rapoo

io 文件读取通用格式

public static void main(String[] args) throws IOException    {        InputStream is = new FileInputStream("D:\\workspace\\files\\test.txt");                byte[] buff = new byte[1024];                //length:以整数形式返回实际读取的字节数        int length;                while (-1 != (length = is.read(buff, 0, 1024)))        {                        String str = new String(buff, 0, length);            System.out.println(str);        }                is.close();    }
?

读书人网 >编程

热点推荐