List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void CacheString(String data, String filename, Context ctx) { try {//from w w w.j a va 2s.c o m FileOutputStream fos = ctx.openFileOutput(filename, Context.MODE_PRIVATE); fos.write(data.getBytes()); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static Bitmap getLoacalBitmap(String url) { try {// w w w . j a v a 2 s.co m java.io.FileInputStream fis = new java.io.FileInputStream(url); return BitmapFactory.decodeStream(fis); } catch (java.io.FileNotFoundException e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static Drawable changeLocalAvatar(Context context, Uri uri) { ContentResolver cr = context.getContentResolver(); Bitmap bitmap = null;/*from www .j av a 2s . c om*/ try { bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri)); } catch (FileNotFoundException e) { e.printStackTrace(); } return new BitmapDrawable(bitmap); }
From source file:Main.java
/** * Write a string value to the specified file. * @param filename The filename/* w w w . j ava 2s . c om*/ * @param value The value */ public static void writeValue(String filename, String value) { try { FileOutputStream fos = new FileOutputStream(new File(filename)); fos.write(value.getBytes()); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static int[] getImageWidhtHeightFromFilePath(String filePath) { try {//from ww w. j a v a2s .com BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; File imageFile = new File(filePath); InputStream is = new FileInputStream(imageFile); BitmapFactory.decodeStream(is, null, options); return new int[] { options.outWidth, options.outHeight }; } catch (FileNotFoundException e) { e.printStackTrace(); return null; } }
From source file:Main.java
/** * Write data to file./* w w w.j av a2 s. c o m*/ * * @param fileName * @param message */ public static void write2File(String fileName, String message, boolean append) { try { FileOutputStream outStream = new FileOutputStream(fileName, append); byte[] bytes = message.getBytes(); outStream.write(bytes); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static OutputStream readFromFile(String path, String fileName) { if (path.charAt(path.length() - 1) != '/') { path += '/'; }//from w w w . j a v a 2 s .c om File file = new File(path + fileName); OutputStream os = null; try { os = new FileOutputStream(file); } catch (FileNotFoundException e) { e.printStackTrace(); } return os; }
From source file:Main.java
public static Bitmap decodeUriToBitmap(Context context, Uri uri) { if (context == null || uri == null) return null; Bitmap bitmap = null;// www . ja va 2s . co m try { bitmap = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri)); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } return bitmap; }
From source file:Main.java
public static Bitmap getLoacalBitmap(String url) { try {//ww w. jav a 2s . c om if (null == url) { return null; } else { FileInputStream fis = new FileInputStream(url); return BitmapFactory.decodeStream(fis); } } catch (FileNotFoundException e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static String getCPUInfo() { try {/* w w w.jav a 2s . c o m*/ FileReader fr = new FileReader("/proc/cpuinfo"); BufferedReader br = new BufferedReader(fr); String text = br.readLine(); String[] array = text.split(":\\s+", 2); br.close(); return array[1]; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }