1 packagecom.udiskrecover;2
3 importjava.awt.Container;4 importjava.awt.FlowLayout;5 importjava.awt.GridLayout;6 importjava.awt.event.ActionEvent;7 importjava.awt.event.ActionListener;8 importjava.io.IOException;9
10 importjavax.swing.JButton;11 importjavax.swing.JFrame;12 importjavax.swing.JLabel;13 importjavax.swing.JOptionPane;14 importjavax.swing.JTextField;15 importjavax.swing.text.AbstractDocument.Content;16
17 /*
18 ############################################################19 # #20 # 【名称】 : U盘EXE恢复工具 #21 # 【作者】 : Sevck(一个写代码很帅的男人) #22 # 【团队】 : 网络尖刀 #23 # 【主页】 :http://sevck.lofter.com#24 # 【日期】 : 2015-10-15 #25 # 【功能】 : 将磁盘上病毒引起的感染EXE通过DOS恢复 #26 # #27 ############################################################28 # ┏┓ ┏┓29 #┏┛┻━━━┛┻┓30 #┃ ┃31 #┃ ━ ┃32 #┃ ┳┛ ┗┳ ┃33 #┃ ┃34 #┃ ``` ┻ ```┃35 #┃ ┃36 #┗━┓ ┏━┛37 #####┃ ┃Code is far away from bug with the animal protecting.38 #####┃ ┃神兽护佑,代码无Bug.39 #####┃ ┗━━━━━┓40 #####┃ ┣┓41 #####┃ ┏┛42 #####┗┓┓┏━┳┓┏┛43 #######┃┫┫ ┃┫┫44 #######┗┻┛ ┗┻┛45 ############################################################46 */
47 public class UDiskRecover extendsJFrame {48
49 JLabel label;50 JTextField text;51 JButton submit;52 String reg = "[a-zA-Z]{1}";53
54 publicUDiskRecover() {55 init();56 }57
58 public voidinit() {59 Container cp = this.getContentPane();60 label = new JLabel("请输入要恢复的磁盘:");61 text = new JTextField(10);62 submit = new JButton("确定");63 cp.add(label);64 cp.add(text);65 cp.add(submit);66
67 this.setSize(300, 200);68 this.setVisible(true);69 this.setDefaultCloseOperation(3);70 //this.setLocationRelativeTo(null);
71 this.setTitle("U盘EXE恢复工具--By:Sevck");72 this.setLayout(new FlowLayout(1, 20, 30));73 this.setResizable(false);74 submit.addActionListener(newActionListener() {75
76 @Override77 public voidactionPerformed(ActionEvent e) {78 //TODO Auto-generated method stub
79
80 String content =text.getText();81 boolean z =content.matches(reg);82 Process process = null;83 if(z) {84 String cmd = "cmd.exe /c attrib -s -h -r " +content85 + ":\\\\* /s /d";86 //String cmd="cmd.exe /c move d:\\1.txt e:\\";87 //String cmd="cmd.exe /c move d:\\1.txt e:\\";88 //System.out.println(newcon);89 //System.out.println(cmd);
90 try{91 process =Runtime.getRuntime().exec(cmd);92 System.out.println(process.toString());93 JOptionPane.showMessageDialog(null, "文件恢复成功!");94 } catch(IOException e1) {95 //TODO Auto-generated catch block
96 e1.printStackTrace();97 JOptionPane.showMessageDialog(null, "文件恢复失败!");98 }99 } else{100 JOptionPane.showMessageDialog(null,101 "请输入正确的盘符!\r\n提示:a-z||A-Z,不需要写“:”.");102 }103 }104 });105
106 }107
108 public static voidmain(String[] args) {109 newUDiskRecover();110 }111 }