有利用過進度條的伴侶一定會感覺很不輕易
因為要從0~100讀取 浪費時間
因檔案大小也不知道這時候間讀寫的完嗎?
如這篇
Java Swing 如何利用進度
於是顛末批改
改成此方法
可使用DIALOG準確的抓到讀寫完成的時候
- processdialog.setTitle("Copying files to USB");
- processdialog.add(labelimg);
- processdialog.setLocation(400,250);
- processdialog.pack(); // Packs the dialog so that the JOptionPane can be seen
- processdialog.setVisible(true); // Shows the dialog網頁設計
- new Thread(){
- public void run(){
- try{
- Process process = null;
- BufferedReader input = null;
- final Runtime runtime = Runtime.getRuntime();
- //extact tar for ext3 file
- String tarstring = "tar -xvpf /"+tarpath+"/"+cellValue+".tar -C "+extpatition+"/";
- process = runtime.exec(new String[]{"/bin/sh","-c",tarstring});
- InputStream stdout = process.getInputStream ();
- InputStreamReader osr = new InputStreamReader (stdout);
- BufferedReader obr = new BufferedReader (osr);
- process.waitFor();
- Thread.sleep(2000);
- }catch(Exception e){
- e.printStackTrace();
- }finally{
- processdialog.dispose();
- }
- }
- }.start();
文章標籤