`

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

	}
}

分享到:
评论
1 楼 虚弱的java 2011-09-14  

相关推荐

Global site tag (gtag.js) - Google Analytics