List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void bitmapToFile(Bitmap bitmap, File file) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos); byte[] bitmapdata = bos.toByteArray(); FileOutputStream fos;/*from w w w.j a v a 2 s . co m*/ try { fos = new FileOutputStream(file); fos.write(bitmapdata); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static boolean saveImage(Bitmap src, String filepath, CompressFormat format) { boolean rs = false; File file = new File(filepath); try {//ww w . j a v a 2s .c om FileOutputStream out = new FileOutputStream(file); if (src.compress(format, 100, out)) { out.flush(); } out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return rs; }
From source file:Main.java
public static File save2File(String savePath, String saveName, String crashReport) { try {/*from ww w . j av a 2s .c om*/ File dir = new File(savePath); if (!dir.exists()) dir.mkdir(); File file = new File(dir, saveName); FileOutputStream fos = new FileOutputStream(file); fos.write(crashReport.toString().getBytes()); fos.close(); return file; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static synchronized void writeArrayListToFile(ArrayList<double[]> x, String filename) { // double []x = {1,2,4}; // String filename = "data.dat"; ObjectOutput out = null;/*from ww w .j a v a 2 s. c om*/ try { out = new ObjectOutputStream(new FileOutputStream(new File(filename))); out.writeObject(x); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static String contentFromFixture(String fixtureName) { BufferedReader br;/* ww w.j a va2s . c om*/ StringBuilder sb = new StringBuilder(); try { br = new BufferedReader( new FileReader("/Users/chang/eclipse/workspace/BasicBlock/src/fixtures/" + fixtureName)); String line = null; while ((line = br.readLine()) != null) { sb.append(line); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return sb.toString(); }
From source file:Main.java
public static String getCpuName() { try {// ww w . j a v a 2s . c om FileReader fr = new FileReader("/proc/cpuinfo"); BufferedReader br = new BufferedReader(fr); String text = br.readLine(); String[] array = text.split(":\\s+", 2); for (int i = 0; i < array.length; i++) { } return array[1]; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String saveToLocal(Bitmap bm) { String path = "/sdcard/test.jpg"; try {/*w w w . ja v a2 s . c o m*/ FileOutputStream fos = new FileOutputStream(path); bm.compress(CompressFormat.JPEG, 75, fos); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } return path; }
From source file:Main.java
public static String simpleCompressImage(String path, String newPath) { Bitmap bitmap = BitmapFactory.decodeFile(path); FileOutputStream outputStream = null; try {//from w w w .j a va 2s .c o m outputStream = new FileOutputStream(newPath); bitmap.compress(Bitmap.CompressFormat.JPEG, 80, outputStream); } catch (FileNotFoundException e) { e.printStackTrace(); } recycle(bitmap); return newPath; }
From source file:Main.java
public static File convertBase64IntoFile(String base64, String path) { File dwldsPath = new File(path); byte[] pdfAsBytes = convertBase64IntoByte(base64); FileOutputStream os;//from ww w . j a v a 2s . c o m try { os = new FileOutputStream(dwldsPath, false); os.write(pdfAsBytes); os.flush(); os.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return dwldsPath; }
From source file:Main.java
private static String storeImage(Context context, Bitmap bitmap) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes); File f = null;//from www. j a va 2s . c o m try { f = File.createTempFile("citationsImg", ".png", context.getExternalCacheDir()); FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return f.getAbsolutePath(); }