List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:FacebookImageLoader.java
public static BitmapFactory.Options getImageSizeFromFile(final String file) { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true;/* w w w . j a v a 2 s.c o m*/ // With inJustDecodeBounds set, we're just going to peek at // the resolution of the image. try { BufferedInputStream is = new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE); BitmapFactory.decodeStream(is, null, opts); is.close(); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } catch (OutOfMemoryError e) { e.printStackTrace(); return null; } return opts; }
From source file:playground.johannes.socialnets.GraphStatistics.java
public static void writeHistogram(Histogram1D hist, String filename) { try {/*w ww . ja v a 2s.c o m*/ BufferedWriter writer = IOUtils.getBufferedWriter(filename); writer.write("x\ty"); writer.newLine(); for (int i = 0; i < 100; i++) { writer.write(String.valueOf(hist.xAxis().binCentre(i))); writer.write("\t"); writer.write(String.valueOf(hist.binHeight(i))); writer.newLine(); } writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.cssweb.android.common.CssIniFile.java
public static void saveIni(Context context, int parmInt, String key, String value) { FileOutputStream fileOut = null; Properties properties = new Properties(); properties.put(key, value);/*from ww w. j ava2 s . com*/ try { fileOut = context.openFileOutput(GetFileName(parmInt), Context.MODE_PRIVATE);// properties.store(fileOut, ""); } catch (FileNotFoundException e) { } catch (IOException e) { } finally { try { fileOut.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:mesquite.tol.lib.BaseHttpRequestMaker.java
public static byte[] doMultipartPost(String url, Map stringParams, Map fileParams) { PostMethod filePost = new PostMethod(url); Part[] parts = new Part[stringParams.size() + fileParams.size()]; int i = 0;//w w w . j a v a2 s .c o m if (stringParams != null) { for (Iterator iter = stringParams.keySet().iterator(); iter.hasNext();) { String nextKey = (String) iter.next(); String nextValue = stringParams.get(nextKey).toString(); parts[i++] = new StringPart(nextKey, nextValue); } } if (fileParams != null) { for (Iterator iter = fileParams.keySet().iterator(); iter.hasNext();) { String nextKey = (String) iter.next(); File nextValue = (File) fileParams.get(nextKey); try { parts[i++] = new FilePart(nextKey, nextValue); } catch (FileNotFoundException e) { e.printStackTrace(); } } } /*System.out.println("going to post multipart to url: " + url + " with parts: " + parts); for (int j = 0; j < parts.length; j++) { Part part = parts[j]; System.out.println("current part is: " + part); }*/ filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams())); //System.out.println("just set request entity"); return executePost(filePost); }
From source file:freebase.api.FreebaseAPI2.java
public static String readQueryFromFile(String filepath) { String result = ""; BufferedReader br = null;/*w ww.j av a2s . c o m*/ try { br = new BufferedReader(new FileReader(filepath)); String line = br.readLine(); while (line != null) { result += line; line = br.readLine(); } return result; } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } return null; }
From source file:Main.java
public static void copyBitmapToTempFile(Uri uri) { File picture = new File(Environment.getExternalStorageDirectory() + "/yourName", "temp"); FileOutputStream out = null;// w w w .j a v a 2 s . com InputStream is = null; try { is = mActivity.getContentResolver().openInputStream(uri); out = new FileOutputStream(picture); byte[] buffer = new byte[1024]; while (is.read(buffer) != -1) { out.write(buffer); } is.close(); is = null; out.close(); out = null; } catch (FileNotFoundException e) { } catch (IOException e) { } finally { try { if (is != null) { is.close(); is = null; } if (out != null) { out.close(); out = null; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:com.db4o.sync4o.ui.Db4oSyncSourceConfigPanel.java
private static void showTestUI() { // Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); // Create and set up the window. JFrame frame = new JFrame("Db4oSyncSourceConfigPanel Test Harness"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create and set up the content pane. final Db4oSyncSource source = new Db4oSyncSource(); Db4oSyncSourceConfigPanel p = new Db4oSyncSourceConfigPanel(); p.setManagementObject(new SyncSourceManagementObject(source, null, null, null, null)); p.updateForm();//from w w w . j a v a 2s.c o m p.setOpaque(true); // content panes must be opaque frame.setContentPane(p); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { XMLEncoder encoder = null; try { FileOutputStream s = new FileOutputStream("test.xml"); encoder = new XMLEncoder(s); encoder.setExceptionListener(new ExceptionListener() { public void exceptionThrown(Exception exception) { exception.printStackTrace(); } }); } catch (FileNotFoundException e) { e.printStackTrace(); System.exit(-1); } encoder.writeObject((Object) source); encoder.flush(); encoder.close(); } }); // Display the window. frame.pack(); frame.setVisible(true); }
From source file:control.LoadControler.java
public static Map<String, List<String>> loadNoms(String filePath) { Map<String, List<String>> map = new HashMap<>(); File folder = new File(userPath(filePath)); Set<File> fileSet = listFilesForFolder(folder); for (File file : fileSet) { try {//www . j a v a 2 s .co m CsvReader reader = new CsvReader(file.getCanonicalPath()); reader.readHeaders(); String[] headersTab = reader.getHeaders(); for (String header : headersTab) { map.put(header, new ArrayList<String>()); } while (reader.readRecord()) { for (String header : headersTab) { String value = reader.get(header); if (!value.isEmpty()) { map.get(header).add(value); } } } reader.close(); } catch (FileNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e); } catch (IOException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e); } } // DEBUG for (String key : map.keySet()) { System.out.print(key + " : "); for (String value : map.get(key)) { System.out.print(value + " "); } System.out.println(); } return map; }
From source file:org.pentaho.support.cmd.CommandLineUtility.java
/** * read support.properties file/* www . j a v a 2s. c om*/ * * @return */ private static Properties loadSupportProperty() { supProp = new StringBuilder(); supProp.append(currentWorkingDirectory).append(File.separator).append(CMDConstant.CMD_RSC) .append(File.separator); Properties props = new Properties(); try { props.load(new FileInputStream(supProp.toString() + File.separator + CMDConstant.SUP_PROP_FILE)); props.put(CMDConstant.ENV_FILE_PATH, supProp.toString() + File.separator + CMDConstant.ENV_FILE_NAME); props.put(CMDConstant.MD5_PATH, supProp.toString()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return props; }
From source file:net.orpiske.ssps.sdm.main.Main.java
/** * Initializes the configuration object//from w w w .j a v a 2s. c o m */ private static void initConfig() { try { ConfigurationWrapper.initConfiguration(Constants.SDM_CONFIG_DIR, Constants.CONFIG_FILE_NAME); } catch (FileNotFoundException e) { System.err.println(e.getMessage()); System.exit(-3); } catch (ConfigurationException e) { System.err.println(e.getMessage()); System.exit(-3); } try { RepositorySettings.initConfiguration(); } catch (SspsException e) { e.printStackTrace(); System.err.println(e.getMessage()); System.exit(-3); } }