List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void saveBitmapForJPG(Bitmap bitmap, String file) { File f = new File(file); FileOutputStream fOut = null; try {//from w ww . j ava2 s . c om fOut = new FileOutputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); try { fOut.flush(); fOut.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void saveJPGE_After(Bitmap bitmap, String path) { File file = new File(path); try {// w ww. jav a2 s. c o m 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 void writeBeanToXml(String path, Object bean) { XMLEncoder encoder = null;//w ww. ja va 2s . c om try { // Serialize object into XML encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(path))); encoder.writeObject(bean); encoder.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (encoder != null) { encoder.close(); } } }
From source file:Main.java
public static void putImageInCache(File file, Bitmap bmp) { try {/*from w w w .ja va 2s . c om*/ file.createNewFile(); FileOutputStream out = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.PNG, 80, out); Log.d("CACHE", "FILE : " + out.toString()); out.flush(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static Bitmap loadImageFromStorage(Context context) { Bitmap bitmap = null;/*from w w w . j ava 2s .c o m*/ try { ContextWrapper cw = new ContextWrapper(context); File directory = cw.getDir("imageDir", Context.MODE_PRIVATE); File f = new File(directory, "gravatar.jpg"); bitmap = BitmapFactory.decodeStream(new FileInputStream(f)); } catch (FileNotFoundException e) { e.printStackTrace(); } return bitmap; }
From source file:Main.java
private static void saveBitmap(Bitmap bitmap, String fileName) { File myCaptureFile = new File(fileName); BufferedOutputStream bos;/* w w w.ja va 2 s .c o m*/ try { bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile)); bitmap.compress(Bitmap.CompressFormat.PNG, 80, bos); bos.flush(); bos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void savePNG_After(Bitmap bitmap, String name) { File file = new File(name); try {/*from ww w. j av a 2 s . com*/ 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
public static void writeFile(byte[] data, File file) { try {//from ww w .j a va 2 s . c om BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, false)); bos.write(data); bos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
static String File2String(String path) { String strReturn = ""; try {// w w w . j a v a 2 s.c o m File f = new File(path); FileInputStream fis = new FileInputStream(f); byte[] bDoc = new byte[fis.available()]; fis.read(bDoc); strReturn = new String(bDoc); fis.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return strReturn; }
From source file:Main.java
public static void createFileFormInputStream(InputStream is, String path) { try {/*w w w . ja v a 2s . com*/ FileOutputStream fos = new FileOutputStream(path); byte[] buf = new byte[1376]; while (is.read(buf) > 0) { fos.write(buf, 0, buf.length); } is.close(); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }