List of usage examples for java.io FileOutputStream close
public void close() throws IOException
From source file:Main.java
public static boolean delete(File file) { file.setWritable(true);/*from ww w .j a v a 2 s.c om*/ try { if (!file.delete()) { FileOutputStream fos = new FileOutputStream(file); fos.write(0); fos.flush(); fos.close(); } Log.d("delete", "Deleted file: " + file + " successfully"); return true; } catch (IOException e) { Log.d("delete", "The deleting file: " + file + " is not successfully", e); return false; } }
From source file:Main.java
public static void saveBitmapToSD(Bitmap bitmap) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/Download"); myDir.mkdirs();/* www.ja va2 s. c o m*/ 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 boolean save_png_from_bitmap(Bitmap bm, String filename) { boolean resultado = true; File f = new File(filename); if (f.exists()) f.delete();/* ww w .ja va2 s . c om*/ try { 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 write(Context context, String fileName, String content) { if (content == null) content = ""; try {/* w w w. java 2 s . c om*/ FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE); fos.write(content.getBytes()); fos.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.bluexml.tools.miscellaneous.Translate.java
public static void writeBackValues(File values, File propertiesFile) throws IOException { List<String> readLines = FileUtils.readLines(values, "UTF-8"); Properties props = new Properties(); TreeMap<String, String> propsMap = loadProperties(propertiesFile); Set<String> keySet = propsMap.keySet(); int index = 0; for (String key : keySet) { String value = readLines.get(index); System.out.println("before trans :" + value); System.out.println("after trans :" + value); System.out.println();//from ww w. ja va2 s .c o m props.setProperty(key, value); index++; } FileOutputStream out = new FileOutputStream(propertiesFile); props.store(out, null); out.close(); }
From source file:Main.java
public static void saveThePicture(Bitmap bitmap, String p) throws Exception { File file = new File(p); FileOutputStream fos = new FileOutputStream(file); // bitmap.//from w w w . j a v a 2 s.c o m if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos)) { fos.flush(); fos.close(); } }
From source file:Main.java
public static void savePNG_After(Bitmap bitmap, String name) { File file = new File(name); try {/* w w w . ja v a 2 s . c om*/ FileOutputStream out = new FileOutputStream(file); if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, out)) { out.flush(); out.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
private static void saveFileForLocal(String requestPath, String result) { // TODO Auto-generated method stub File file = new File(requestPath); if (!file.exists()) { try {/*www.j ava2 s. c o m*/ File parentFile = file.getParentFile(); if (!parentFile.exists()) { parentFile.mkdirs(); } file.createNewFile(); FileOutputStream fout = new FileOutputStream(file); byte[] buffer = result.getBytes(); fout.write(buffer); fout.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:Main.java
public static void saveJPGE_After(Bitmap bitmap, String path) { File file = new File(path); try {/* w w w . j ava2s . c om*/ FileOutputStream out = new FileOutputStream(file); if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)) { out.flush(); out.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static boolean save(Bitmap bitmap, String filepath) { try {/*w ww . j av a 2s . co m*/ FileOutputStream fos = new FileOutputStream(filepath); bitmap.compress(CompressFormat.JPEG, 100, fos); bitmap.recycle(); fos.close(); return true; } catch (FileNotFoundException e) { } catch (IOException e) { } return false; }