List of usage examples for java.io File delete
public boolean delete()
From source file:Main.java
/** * Delete a file/*from w ww . j av a 2 s . c o m*/ * * @param path the path to the file * @param fileName the name of the file to delete */ @SuppressWarnings("UnusedReturnValue") public static boolean deleteFile(File path, String fileName) { File file = new File(path, fileName); return file.delete(); }
From source file:Main.java
public static void RecursionDeleteFile(File file) { if (file.isFile()) { file.delete(); return;//ww w . ja v a 2 s . c om } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { RecursionDeleteFile(f); } file.delete(); } }
From source file:Main.java
public static boolean delete(String fName) { File f = new File(fName); if (f.exists()) { return f.delete(); } else {/*from w ww . ja v a 2s . com*/ return false; } }
From source file:Main.java
/** * Attempts to delete the specified file. If it cannot be deleted, it is * flagged as deleteOnExit.//ww w . j a va 2 s . c o m */ static public void deleteFile(File p_tmpFile) { try { p_tmpFile.delete(); } catch (Exception ex) { // ignore - tmp file may not be deletable on windows } finally { if (p_tmpFile.exists()) { // Tell VM to delete file on exit when it still exists. p_tmpFile.deleteOnExit(); } } }
From source file:Main.java
public static void clearTempDirectory() { // Abandon if we created no files in this session if (tempFileList.size() == 0) return;/*w w w .j av a 2s.c om*/ Iterator i = tempFileList.iterator(); while (i.hasNext()) { try { File f = new File((String) i.next()); f.delete(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:Main.java
public static void delete(File file) { if (file.isFile()) { file.delete(); return;/*from w w w. j a va 2 s.co m*/ } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { delete(f); } file.delete(); } }
From source file:Main.java
public static void deleteFile(File file) { if (file.isFile()) { file.delete(); return;/*from ww w . j av a 2 s . c om*/ } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { deleteFile(f); } file.delete(); } }
From source file:Main.java
public static void intArrayToFile(Context myContext, String filename, int[] array) { File root = myContext.getFilesDir(); File current = new File(root, filename); current.delete(); FileOutputStream outputStream; try {/*from w ww . java 2 s .com*/ outputStream = myContext.openFileOutput(filename, Context.MODE_APPEND); for (int i : array) { String s = "" + i; outputStream.write(s.getBytes()); outputStream.write("\n".getBytes()); } outputStream.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void deleteFile(File file) { try {// w ww . j ava2 s . c o m if (file.exists()) file.delete(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
/** * task:delete recording/*from w w w .j ava 2 s . c om*/ * @param filePath file path */ public static void deleteRecording(String filePath) { File file = new File(filePath); if (file.exists()) { file.delete(); } }