Java_I/O输入输出_实现读取文件时出现一个表示读取进度的进度条。可以使用java.swing包提供的输入流类ProgressMonitorInputStream
import java.io.*;
import javax.swing.*;
public class Student {
public static void main(String[] temp) {
byte b[] = new byte[2];
try{
FileInputStream fis = new FileInputStream("word.txt");
ProgressMonitorInputStream in =
new ProgressMonitorInputStream(null,"读取文件",fis);
while(in.read(b)!=-1){
String s = new String(b);
System.out.print(s);
Thread.sleep(10);
}
}catch (Exception e) {
e.printStackTrace();
}
}
}
大家可以思考加百分比怎么加!!!!!