62,614
社区成员
发帖
与我相关
我的任务
分享
Thread t=new Thread(){
public void run(){
FileInputStream fis=null;
FileOutputStream fos=null;
try {
fis=new FileInputStream(sourceText.getText());
fos=new FileOutputStream(newText.getText());
bar.setMaximum((int)l);
while(fis.available()>0){
fos.write(fis.read()^Integer.parseInt(text.getText()));//文件加密
bar.setValue(i++);
try {
Thread.sleep(10);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
JOptionPane.showMessageDialog(frame, "文件加密/解密成功!");
clear();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}finally{
try {
if(fis!=null){ fis.close();}
if(fos!=null){fos.close();}
} catch (IOException ex) {}
}
}
};
t.start();