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();
}
}
}

大家可以思考加百分比怎么加!!!!!

posted @ 2016-10-09 15:51  漂洋过海的鱼  阅读(3917)  评论(0编辑  收藏  举报