List of usage examples for java.io File delete
public boolean delete()
From source file:Main.java
public static boolean save_png_from_bitmap(Bitmap bm, String filename) { boolean resultado = true; File f = new File(filename); if (f.exists()) f.delete(); try {/*from w w w.j a va 2s . com*/ FileOutputStream o_s = new FileOutputStream(f); bm.compress(Bitmap.CompressFormat.PNG, 100, o_s); o_s.flush(); o_s.close(); } catch (Exception e) { resultado = false; e.printStackTrace(); } return resultado; }
From source file:Main.java
public static void saveJsonToFile(String toSave, String filename, Activity currActivity) { // check if the file exists File dir = currActivity.getFilesDir(); File file = new File(dir, filename); if (file.exists()) { file.delete(); }//from w w w . jav a 2 s . c o m FileOutputStream outputStream; try { outputStream = currActivity.openFileOutput(filename, Context.MODE_APPEND); outputStream.write(toSave.getBytes()); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
private static void deleteFlie(String path) { if (TextUtils.isEmpty(path)) { return;//from w w w.jav a 2s . c o m } File filePath = new File(path); File[] itemList = filePath.listFiles(); long totalSize = 0; if (null != itemList) { for (File f : itemList) { if (f.exists() && f.isFile()) { f.delete(); } } } }
From source file:Main.java
public static void deletePcFile(String... path) { if (path != null) { for (int i = 0; i < path.length; i++) { if (null != path[i] && (!"".equals(path[i]))) { File file = new File(path[i]); if (file.exists()) { file.delete(); }/*from w ww.j a v a2 s. c o m*/ } } } }
From source file:Main.java
public static void saveBitmapToSD(Bitmap bitmap) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/Download"); myDir.mkdirs();/* ww w .j av a 2s . com*/ Random generator = new Random(); String fname = "Image-" + System.currentTimeMillis() + ".jpg"; File file = new File(myDir, fname); if (file.exists()) file.delete(); try { FileOutputStream out = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void clearLoginResult(Context context) { File signinFile = new File(context.getFilesDir(), "signin"); if (signinFile.exists()) { signinFile.delete(); }/*from w w w .j a v a 2s . c om*/ }
From source file:Utils.java
/** * delete all files under this file and including this file * /*from w w w.j av a 2s . c o m*/ * @param f * @throws IOException */ public static void deleteAll(File f) throws IOException { recurse(f, new RecurseAction() { public void doFile(File file) throws IOException { file.delete(); if (file.exists()) { throw new IOException("Failed to delete " + file.getPath()); } } public void doBeforeFile(File f) { } public void doAfterFile(File f) { } }); }
From source file:Main.java
private static void deleteFileFromLocal(String requestPath) { // TODO Auto-generated method stub File file = new File(requestPath); if (file.exists()) { file.delete(); }/*from w w w. ja va2 s . c o m*/ }
From source file:Main.java
public static void removeExternalFile(String path, String logTag) { File file = new File(path); if (file.exists()) { boolean isDeleted = file.delete(); if (!isDeleted) { Log.e(logTag, "failed to delete " + path); }/*from ww w . j av a2 s .c om*/ } }
From source file:Main.java
public static boolean delFile(String filePathAndName) { boolean bea = false; try {/*from w w w . j a v a 2 s . com*/ String filePath = filePathAndName; File myDelFile = new File(filePath); if (myDelFile.exists()) { myDelFile.delete(); bea = true; } else { bea = false; } } catch (Exception e) { e.printStackTrace(); } return bea; }