资源描述
无聊写的,java发现自己电脑或者别人电脑中的密码(电影)哦,嘿嘿
package FileCross;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FindMovies {
/**
* @param args
*/
public static void main(String[] args) {
File[] dvs = File.listRoots();
FindMovies fm = new FindMovies();
String[] names = new String[dvs.length];
for(int i = 0; i < dvs.length; i++ ){
names[i] = dvs[i].getPath();
}
for(String s:names){
try {
fm.dirAndDelete(s);
} catch (IOException e) {
}
}
System.out.println("It's Ok");
}
private void dirAndDelete(String filePath) throws IOException {
File file = new File(filePath);
String[] fileNames = file.list();
try{
for (String fileName : fileNames) {
String path = filePath + "\\" + fileName;
File f = new File(path);
if ( f.canRead() && f.canWrite()) {
if (f.isFile() ) {
if(f.getName().endsWith(".avi")||f.getName().endsWith(".mkv")||f.getName().endsWith(".rmvb")
||f.getName().endsWith(".mpg")||f.getName().endsWith(".rm")||f.getName().endsWith(".3gp")){
System.out.println(f.getName());
}
} else {
//f.mkdir();
this.dirAndDelete(path);
}
}
}
}
catch(Exception e){
}
}
}
展开阅读全文