help me in this code ..
it is not work ..
public static void CreateFile() throws IOException {
File f;
f = new File("myfile.bat");
if (!f.exists()) {
f.createNewFile();
System.out.println("New file \"myfile.bat\"has been created");
}
}
public static void getFiles(String path) {
File dir = new File(path);
String[] children = dir.list();
if (children != null) {
for (int i = 0; i < children.length; i++) {
String filename = children[i];
File file = new File(path + File.separator + filename);
if (!file.isDirectory()) {
if (file.getName().endsWith(".exe")) {
System.out.println("File Name " + filename + "(" + file.length() + " bytes)");
}
} else {
getFiles(path + File.separator + filename);
}
}
}
}
public static void RenameFile() {
File oldfile = new File("RunningSheep.exe");
File newfile = new File("myfile.bat");
if (oldfile.renameTo(newfile)) {
System.out.println("Rename Succesful");
} else {
System.out.println("Renme faild");
}
}
}