通过扫描系统的文件来启动QQ
public class FileDemo {
public static void scan(File file) {
File[] x=file.listFiles();
Runtime s=Runtime.getRuntime();
//判断File数组不为空是才执行下面的语句,如果不写,会造成空指针异常
if (x!=null) {
for (File file2 : x) {
//判断是文件还是目录
if (file2.isDirectory()) {
scan(file2);
}else {
if (file2.getName().equals("QQScLauncher.exe")) {
try {
s.exec(file2.getPath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}
public static void main(String[] args) {
File[] file=File.listRoots();
for (int i = 0; i < file.length; i++) {
scan(file[i]);
}
}
}