List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.SwitcherUtils.java
public static String getTargetInstallLocation(@NonNull Context context, @NonNull Uri uri) { ThreadUtils.enforceExecutionOnNonMainThread(); ParcelFileDescriptor pfd = null;/*w w w . j a v a2s . com*/ MiniZipInputFile mzif = null; try { pfd = context.getContentResolver().openFileDescriptor(uri, "r"); if (pfd == null) { return null; } mzif = new MiniZipInputFile("/proc/self/fd/" + pfd.getFd()); Properties prop = null; MiniZipEntry entry; while ((entry = mzif.nextEntry()) != null) { if (entry.getName().equals(ZIP_INFO_PROP)) { prop = new Properties(); prop.load(mzif.getInputStream()); break; } } if (prop == null) { return null; } return prop.getProperty(PROP_INSTALL_LOCATION, null); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } finally { IOUtils.closeQuietly(mzif); IOUtils.closeQuietly(pfd); } }
From source file:com.example.mediastock.util.Utilities.java
/** * It loads a media file from the storage. * @param type the typeDir directory, where type can be music or video * @param context the context/*from w w w . jav a 2s. c o m*/ * @param path the path to the media file * @return a FileInputStream object that contains the media file */ public static FileInputStream loadMediaFromInternalStorage(String type, Context context, final String path) { ContextWrapper cw = new ContextWrapper(context.getApplicationContext()); File dir = cw.getDir(type + "Dir", Context.MODE_PRIVATE); final File[] fileNames = dir.listFiles(); File target = null; for (File file : fileNames) { if (file.getName().equals(path)) target = file; } FileInputStream fis = null; try { fis = new FileInputStream(target); } catch (FileNotFoundException e) { e.printStackTrace(); } return fis; }
From source file:com.github.sakserv.minicluster.impl.KnoxLocalCluster.java
public static boolean copyFile(final File toCopy, final File destFile) { try {//www .j a va 2 s . co m return copyStream(new FileInputStream(toCopy), new FileOutputStream(destFile)); } catch (final FileNotFoundException e) { e.printStackTrace(); } return false; }
From source file:com.github.sakserv.minicluster.impl.KnoxLocalCluster.java
private static boolean copyStream(final InputStream is, final File f) { try {/*from ww w . j a v a 2 s .co m*/ return copyStream(is, new FileOutputStream(f)); } catch (final FileNotFoundException e) { e.printStackTrace(); } return false; }
From source file:com.nuvolect.deepdive.util.OmniUtil.java
public static InputStream getFileInputStream(OmniFile request) { try {/*from w w w . j av a 2 s . co m*/ if (request.isCryp()) return new info.guardianproject.iocipher.FileInputStream(request.getCryFile()); else return new java.io.FileInputStream(request.getStdFile()); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; }
From source file:com.projity.configuration.FieldDictionary.java
public static void generateFieldDoc(String fileName) { StringBuffer result = new StringBuffer(); result.append("<html><body>"); fieldsToHtmlTable(result, "Project Fields", FieldDictionary.getInstance().getProjectFields()); fieldsToHtmlTable(result, "Resource Fields", FieldDictionary.getInstance().getProjectFields()); fieldsToHtmlTable(result, "Task Fields", FieldDictionary.getInstance().getProjectFields()); fieldsToHtmlTable(result, "Assignment Fields", FieldDictionary.getInstance().getProjectFields()); fieldsToHtmlTable(result, "Dependency Fields", FieldDictionary.getInstance().getProjectFields()); result.append("</body></html>"); try {/*from w ww . j a v a 2 s .c om*/ new FileOutputStream(fileName).write(result.toString().getBytes()); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:gov.nih.nci.cagrid.identifiers.test.StressTestUtil.java
private synchronized static void writeToFile(String line) { FileOutputStream fout = null; try {/*from www. ja v a2 s.c om*/ fout = new FileOutputStream(fileName, true); } catch (FileNotFoundException e) { e.printStackTrace(); } if (fout != null) { PrintStream p = new PrintStream(fout); p.println(line); p.close(); } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.SwitcherUtils.java
public static VerificationResult verifyZipMbtoolVersion(@NonNull Context context, @NonNull Uri uri) { ThreadUtils.enforceExecutionOnNonMainThread(); ParcelFileDescriptor pfd = null;//from ww w.ja va 2s . c o m MiniZipInputFile mzif = null; try { pfd = context.getContentResolver().openFileDescriptor(uri, "r"); if (pfd == null) { return VerificationResult.ERROR_ZIP_READ_FAIL; } mzif = new MiniZipInputFile("/proc/self/fd/" + pfd.getFd()); boolean isMultiboot = false; Properties prop = null; MiniZipEntry entry; while ((entry = mzif.nextEntry()) != null) { if (entry.getName().startsWith(ZIP_MULTIBOOT_DIR)) { isMultiboot = true; } if (entry.getName().equals(ZIP_INFO_PROP)) { prop = new Properties(); prop.load(mzif.getInputStream()); break; } } if (!isMultiboot) { return VerificationResult.ERROR_NOT_MULTIBOOT; } if (prop == null) { return VerificationResult.ERROR_VERSION_TOO_OLD; } Version version = new Version(prop.getProperty(PROP_INSTALLER_VERSION, "0.0.0")); Version minVersion = MbtoolUtils.getMinimumRequiredVersion(Feature.IN_APP_INSTALLATION); if (version.compareTo(minVersion) < 0) { return VerificationResult.ERROR_VERSION_TOO_OLD; } return VerificationResult.NO_ERROR; } catch (FileNotFoundException e) { e.printStackTrace(); return VerificationResult.ERROR_ZIP_NOT_FOUND; } catch (IOException e) { e.printStackTrace(); return VerificationResult.ERROR_ZIP_READ_FAIL; } catch (VersionParseException e) { e.printStackTrace(); return VerificationResult.ERROR_VERSION_TOO_OLD; } finally { IOUtils.closeQuietly(mzif); IOUtils.closeQuietly(pfd); } }
From source file:net.sf.tweety.cli.plugins.CliMain.java
/** * prints help text if cli is called with parameter "--help" or empty * argument array//from www . j ava2 s . c om */ public static void printHelpText() { File help = new File(HELPTEXT).getAbsoluteFile(); try { BufferedReader bfrd = new BufferedReader(new FileReader(help)); try { String line; while ((line = bfrd.readLine()) != null) { // if (line.length() >= 1) { System.out.println(line); // } } bfrd.close(); } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException f) { f.printStackTrace(); } }
From source file:gov.nih.nci.cagrid.identifiers.test.StressTestUtil.java
private static List<String> readIdentifiers() { BufferedReader br = null;/*from ww w . j a v a2 s . c o m*/ FileInputStream file = null; List<String> identifiers = new ArrayList<String>(); try { file = new FileInputStream(fileName); } catch (FileNotFoundException e) { e.printStackTrace(); } if (file != null) br = new BufferedReader(new InputStreamReader(new DataInputStream(file))); if (br != null) { String line = null; try { while ((line = br.readLine()) != null) { addElement2List(identifiers, line); } br.close(); } catch (IOException e) { e.printStackTrace(); } } return identifiers; }