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

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM