黑马程序员技术交流社区
标题:
输入流问题
[打印本页]
作者:
RichardM
时间:
2015-7-27 21:22
标题:
输入流问题
要求:定义一个文件输入流,调用read(byte[] b)方法将exercise.txt文件中的所有内容打印出来(byte数组的大小限制为5)。
作者:
真实姓名被注册
时间:
2015-7-27 23:50
要求:定义一个文件输入流,调用read(byte[] b)方法将exercise.txt文件中的所有内容打印出来(byte数组的大小限制为5)。
public static void print(){
BufferedReader br=null;
try{
br=new BufferedReader(new FileReader("exercise.txt"));
byte[] b=new byte[5];
int len=0;
while((len=br.read(b))!=-1){
System.out.print(new String(b,0,len));
}
}catch(IOException e){
throw e;
}finally{
if(br!=null)
try{
br.close();
}catch(IOException e){
throw e;
}
}
}
作者:
aurora_bessie
时间:
2015-7-29 23:33
楼上的解答是
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2