首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

IO(1)

2012-10-06 
IO(一)代码例子package com.testimport java.io.FileInputStreamimport java.io.IOExceptionimport jav

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();}}

热点排行