我的一个程序中的Stream在一个循环后 后面的语句不执行 请问怎么解决
public void read(String fname)
{
File f=new File(fname);
try
{
FileInputStream fin=new FileInputStream(f);
DataInputStream ois=new DataInputStream(fin);
int i=ois.readInt(),p;
while(i!=-1)
{
System.out.print(i);
char ch;
while((ch=ois.readChar())!='\n')
{
if(ch!='#')
System.out.print(ch);
else
System.out.print(" ");
}
System.out.println();
p=i;
i=ois.readInt();//最后i的值无的话就异常抛出了 好像
}
System.out.println("dfsdfsd");//这里开始不执行
fin.close();
ois.close();
}
catch(IOException ioe){} }
public void read(String fname)
{
File f=new File(fname);
try
{
FileInputStream fin=new FileInputStream(f);
DataInputStream ois=new DataInputStream(fin);
int i=ois.readInt(),p;
while(i!=-1)
{
System.out.print(i);
char ch;
while((ch=ois.readChar())!='\n')
{
if(ch!='#')
System.out.print(ch);
else
System.out.print(" ");
}
System.out.println();
p=i;
i=ois.readInt();//最后i的值无的话就异常抛出了 好像
}
System.out.println("dfsdfsd");//这里开始不执行
fin.close();
ois.close();
}
catch(IOException ioe){} }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货