读书人

IO(1)

发布时间: 2012-10-06 17:34:01 作者: rapoo

IO(一)
代码例子

package com.test;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;public class InputStreamTest{public static void main(String[] args) throws IOException{InputStream in = new FileInputStream("c:/hello.txt");         byte[] buffer = new byte[200];int length = 0;while (-1 != (length = in.read(buffer, 0, 200))){String str = new String(buffer,0,length);System.out.println(str);}in.close();}}

读书人网 >编程

热点推荐