// formateaza un disk public void format() { File root = new File(currentDiskPath); File[] listOfFiles = root.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { delete(listOfFiles[i]); } System.out.println("Format succesfull!"); takePath(); }
public static void delete(File file) { if (file.isFile()) file.delete(); File[] files = file.listFiles(); if (files != null) { // some JVMs return null for empty dirs for (File f : files) { if (f.isDirectory()) { delete(f); } else { f.delete(); } } } file.delete(); }
// sterge un fisier/director cu numele name public void delete(String name) throws PhileNotFoundException { File targetFile = new File(currentPath + "\\" + name); if (targetFile.exists()) delete(targetFile); takePath(); }