![]() |
#2
林月儿2015-12-23 20:44
|

import *;
public class Text
{
public static void main(String[] args) throws IOException
{
try
{
FileInputStream fis =new FileInputStream("Text.java");
byte[]b=new byte[1024];
int hasRead=0;
while((hasRead=fis.read(b))>0)//请问一下,这里为什么要将fis.read(b)赋给一个int变量,直接写fis.read(b)>0的话会报错
{
System.out.print(new String(b,0,hasRead));//如果上面只写fis.read(b)>0的话,这里也要改
}
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
public class Text
{
public static void main(String[] args) throws IOException
{
try
{
FileInputStream fis =new FileInputStream("Text.java");
byte[]b=new byte[1024];
int hasRead=0;
while((hasRead=fis.read(b))>0)//请问一下,这里为什么要将fis.read(b)赋给一个int变量,直接写fis.read(b)>0的话会报错
{
System.out.print(new String(b,0,hasRead));//如果上面只写fis.read(b)>0的话,这里也要改
}
}
catch(IOException e)
{
e.printStackTrace();
}
}
}