日期:2014-05-20  浏览次数:20632 次

fileinputStream问题
import java.io.*;

public class TestFileInputStream {
public static void main(String[] args){
int b = 0;
FileInputStream in = null;
try{
in = new FileInputStream("D:\\JAVA1\\TestFileInputStream.java");
}
catch(FileNotFoundException e){
System.out.println("指定文件不存在");
System.exit(-1);
}

try{
long num = 0;
while((b=in.read())!=1){
System.out.print((char)b);
num++;
}
in.close();
System.out.println();
System.out.println("一共读取了"+num+"个字节");
}
catch(IOException e1){
System.out.println("错误");
System.exit(-1);
}
}
}


该程序在dos里面一运行就出现死循环,一直出问号。哪位大侠解释下

------解决方案--------------------
while((b=in.read())!=-1){