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里面一运行就出现死循环,一直出问号。哪位大侠解释下
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里面一运行就出现死循环,一直出问号。哪位大侠解释下
解决方案 »
- 一个ServerSocket 服务端在同一个端口上能并发的连接20个客户端吗?
- 几个老的JAVA问题
- 关于struts1.x中的html:messages标签的使用
- java 线程问题 急~~~
- 如何改变JButton文字内容的字体?
- <thinking in java>那里有??
- 大家都来谈谈自己学习Java的经验或看法!(来者有分)
- 请教个问题,怎么查找文件中的半角字符,并把它全部替换为想应的全角字符
- 成功兼职两周,散分
- 怎样从执行文件启动java程序,以避免出现那个控制台窗口,好象用javaw.exe也会有一个dos窗口弹出来呵,请高手指点
- java十六进制取值的问题
- 使用Graphics绘图简单例子问题
死循环。流读完会返回-1,改成b=in.read())!=-1 。这是死循环的原因。