import javax.swing.*;
import java.io.*;
public class TestPrggress {
    ProgressMonitor pm;
    public TestPrggress() {
        try {
            File f=new File("d:/1.txt");
            long l=f.length();
            int i=(int)l;
            //FileReader in=new FileReader(f); //1
            BufferedInputStream in=new BufferedInputStream(new FileInputStream(f)); //2
            pm=new ProgressMonitor(null,"readfile...","1.txt",0,in.available()); //3
            int j,c=0;
            while((j=in.read())!=-1)
            {
                Thread.sleep(1);
                System.out.print((char)j);
                pm.setProgress(++c);
            }
            in.close();
        }
        catch(Exception e){System.out.print(“error");}
    }
    public static void main(String args[])
    {
        new TestPrggress();
        
    }
}
注释掉1程序正常
但是注释掉2
然后把3改为pm=new ProgressMonitor(null,"readfile...","1.txt",0,i);
文件读到一半就停止了
究竟是什么原因呀?