List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:at.wada811.dayscounter.CrashExceptionHandler.java
public static void makeReportFile(Context context, Throwable throwable) { PrintWriter writer = null;//from w w w. ja va 2s. com FileOutputStream outputStream; try { outputStream = context.openFileOutput(FILE_NAME, Context.MODE_PRIVATE); writer = new PrintWriter(outputStream); String report = CrashExceptionHandler.makeReport(context, throwable); writer.print(report); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (writer != null) { writer.close(); } } }
From source file:IO.java
public static double[][] readBinaryData(File file, int nData, int nDim) { FileInputStream inStream;/*from w ww . ja va 2 s .c om*/ double[][] data = new double[nData][nDim]; try { inStream = new FileInputStream(file); DataInputStream input = new DataInputStream(inStream); for (int i = 0; i < nData; i++) for (int j = 0; j < nDim; j++) { data[i][j] = input.readDouble(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return data; }
From source file:IO.java
public static void writeData(int[] data, int nData, String filepath) { File file = new File(filepath); PrintWriter writer;//from w ww .j av a 2 s. c o m try { writer = new PrintWriter(file); for (int i = 0; i < nData; i++) { if (i == nData - 1) { writer.print(data[i]); } else { writer.print(data[i] + ","); } } writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
From source file:IO.java
public static void writeData(int[][] data, int nData, int nDim, String filepath) { File file = new File(filepath); PrintWriter writer;//from ww w.ja va2 s . c om try { writer = new PrintWriter(file); for (int i = 0; i < nData; i++) { for (int j = 0; j < nDim; j++) { if (j == nDim - 1) { writer.print(data[i][j]); } else { writer.print(data[i][j] + ","); } } writer.println(); } writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
From source file:org.processbase.ui.core.Constants.java
public static Properties getJournalProperties(String domain) { if (StringUtils.isEmpty(domain)) domain = "default"; if (journalProperties.containsKey(domain)) return journalProperties.get(domain); String userHomeDir = BonitaConstants.getBonitaHomeFolder(); File file = new File(userHomeDir + "/server/" + domain + "/conf/bonita-journal.properties"); FileInputStream in = null;//from w w w .j a v a2s . co m try { in = new FileInputStream(file); Properties properties = new Properties(); properties.load(in); journalProperties.put(domain, properties); return properties; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } return null; }
From source file:com.asksven.commandcenter.valueobjects.CommandReaderWriter.java
public static void writeFile(Context ctx, CommandCollection data, String strFileName) { try {//from www . j av a 2 s. c om FileOutputStream target = new FileOutputStream( DataStorage.getExternalStoragePath(ctx) + "/" + strFileName); writeStream(data, target); target.close(); } catch (FileNotFoundException e) { Log.e(TAG, "File could not be written: " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { Log.e(TAG, "File could not be closed: " + e.getMessage()); e.printStackTrace(); } }
From source file:IO.java
public static void writeData(double[][] data, int nData, int nDim, String filepath) { File file = new File(filepath); PrintWriter writer;//from w w w. ja va 2 s . com try { writer = new PrintWriter(file); for (int i = 0; i < nData; i++) { for (int j = 0; j < nDim; j++) { if (j == nDim - 1) { writer.print(data[i][j]); } else { writer.print(data[i][j] + ","); } } writer.println(); } writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
From source file:com.log4ic.compressor.utils.FileUtils.java
/** * ?//from ww w . j a va 2 s .co m * * @param content * @param filePath * @return */ public static File writeFile(byte[] content, String filePath) { FileOutputStream out = null; FileChannel outChannel = null; File file = new File(filePath); if (file.exists()) { file.delete(); } if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } ByteBuffer outBuffer = ByteBuffer.allocate(content.length); outBuffer.put(content); outBuffer.flip(); try { out = new FileOutputStream(file); outChannel = out.getChannel(); outChannel.write(outBuffer); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (outChannel != null) { try { outChannel.close(); } catch (IOException e) { e.printStackTrace(); } } if (out != null) { try { out.flush(); } catch (IOException e) { e.printStackTrace(); } try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } return file.exists() ? file : null; }
From source file:com.tc.utils.DxlUtils.java
private static void write(File dir, String fileName, byte[] byteMe) { OutputStream out = null;// www . ja v a2s . c o m try { out = new FileOutputStream(dir.getPath() + IOUtils.DIR_SEPARATOR + fileName); IOUtils.write(byteMe, out); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(out); } }
From source file:com.mycompany.craftdemo.utility.java
public static JSONObject getConfig(String filePath) { try {//from ww w . j a v a2 s .co m // read the json file FileReader reader = new FileReader(filePath); JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = (JSONObject) jsonParser.parse(reader); return jsonObject; } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } catch (ParseException ex) { ex.printStackTrace(); } catch (NullPointerException ex) { ex.printStackTrace(); } return null; }