private PGPPublicKey getPubKey() { InputStream pubKeyIS; try { pubKeyIS = new BufferedInputStream(new FileInputStream(config.getPgpPublicKeyLoc())); } catch (FileNotFoundException e) { logger.error( "Exception in reading PGP security collection ring. Msg: {}", e.getLocalizedMessage()); throw new RuntimeException("Exception in reading PGP public key", e); } try { return PgpUtil.readPublicKey(pubKeyIS); } catch (Exception e) { throw new RuntimeException("Exception in reading & deriving the PGP public key.", e); } }
@Override public BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath) { MetaFileBackupValidator metaFileBackupValidator = new MetaFileBackupValidator(); BackupVerificationResult result = metaFileBackupValidator.verificationResult; result.remotePath = metaBackupPath.getRemotePath(); result.snapshotInstant = metaBackupPath.getLastModified(); Path metaFile = null; try { metaFile = downloadMetaFile(metaBackupPath); result.manifestAvailable = true; metaFileBackupValidator.readMeta(metaFile); result.valid = (result.filesInMetaOnly.isEmpty()); } catch (FileNotFoundException fne) { logger.error(fne.getLocalizedMessage()); } catch (IOException ioe) { logger.error( "IO Error while processing meta file: " + metaFile, ioe.getLocalizedMessage()); ioe.printStackTrace(); } catch (BackupRestoreException bre) { logger.error("Error while trying to download the manifest file: {}", metaBackupPath); } finally { if (metaFile != null) FileUtils.deleteQuietly(metaFile.toFile()); } return result; }
requestCallback).executeAsync(); } catch (final FileNotFoundException ex) { String message = ex.getLocalizedMessage(); if (message == null) { message = "Error staging photo.";
public static Properties loadPropertiesFromURL(URL propsURL) { final Properties properties = new Properties(); InputStream stream = null; InputStream openStream = null; try { openStream = propsURL.openStream(); stream = new BufferedInputStream(openStream); properties.load(stream); } catch (FileNotFoundException e) { if (LOGGER.isLoggable(Level.SEVERE)) LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); return null; } catch (IOException e) { if (LOGGER.isLoggable(Level.SEVERE)) LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); return null; } finally { if (stream != null) { IOUtils.closeQuietly(stream); } if (openStream != null) { IOUtils.closeQuietly(openStream); } } return properties; } }
/** * Store the properties on disk * * @param properties * @param typeName */ protected void storeProperties(Properties properties, String typeName) { OutputStream outStream = null; try { final String propertiesPath = auxiliaryFolder.getAbsolutePath() + File.separatorChar + typeName + ".properties"; outStream = new BufferedOutputStream(new FileOutputStream(new File(propertiesPath))); properties.store(outStream, null); } catch (FileNotFoundException e) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Unable to store the mapping " + e.getLocalizedMessage()); } } catch (IOException e) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Unable to store the mapping " + e.getLocalizedMessage()); } } finally { if (outStream != null) { IOUtils.closeQuietly(outStream); } } }
/** * Utility method which load mapping properties from a propertiesFile. * * @param propertiesFile * @return */ private static Properties loadProperties(final String propertiesFile) { InputStream inStream = null; Properties properties = new Properties(); try { File propertiesFileP = new File(propertiesFile); inStream = new BufferedInputStream(new FileInputStream(propertiesFileP)); properties.load(inStream); } catch (FileNotFoundException e) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Unable to store the mapping " + e.getLocalizedMessage()); } } catch (IOException e) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Unable to store the mapping " + e.getLocalizedMessage()); } } finally { if (inStream != null) { IOUtils.closeQuietly(inStream); } } return properties; }
} catch (FileNotFoundException e) { if (FeatureUtilities.LOGGER.isLoggable(Level.SEVERE)) FeatureUtilities.LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); return null; } catch (IOException e) {
LOGGER.warning(e.getLocalizedMessage());
/** * conditionally create messages bundle for proper locale, not on classpath so need to handle manually * @return a resource bundle for default locale, or USA if default locale's language has no translated messages */ static ResourceBundle createResourceBundle() { ResourceBundle temp = null; try { temp = new PropertyResourceBundle(new FileInputStream( DirectoryManager.injectFileSystemSeparators( DirectoryManager.getProjectI18nDir(), new StringBuilder("messages_").append( Locale.getDefault().getLanguage()).append( ".properties").toString()))); } catch(FileNotFoundException x) { try { Logger.getLogger(Strings.class.getName()).log(Level.INFO, "Your default language is not supported yet. "+x.getLocalizedMessage()); temp = new PropertyResourceBundle(new FileInputStream( DirectoryManager.injectFileSystemSeparators( DirectoryManager.getProjectI18nDir(), "messages_en.properties"))); } catch (Exception e) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); } return temp; }
return grid; } catch (FileNotFoundException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); return null; } catch (IOException e) {
LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e);
public static boolean exportRules(Context ctx, final String fileName) { boolean res = false; File sdCard = Environment.getExternalStorageDirectory(); if (isExternalStorageWritable()) { File dir = new File(sdCard.getAbsolutePath() + "/afwall/"); dir.mkdirs(); File file = new File(dir, fileName); try { FileOutputStream fOut = new FileOutputStream(file); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); //default Profile - current one JSONObject obj = new JSONObject(getCurrentRulesAsMap(ctx)); JSONArray jArray = new JSONArray("[" + obj.toString() + "]"); myOutWriter.append(jArray.toString()); res = true; myOutWriter.close(); fOut.close(); } catch (FileNotFoundException e) { Log.e(TAG, e.getLocalizedMessage()); } catch (JSONException e) { Log.e(TAG, e.getLocalizedMessage()); } catch (IOException e) { Log.e(TAG, e.getLocalizedMessage()); } } return res; }
LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } catch (IOException e) {
LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e);
LOGGER.log(Level.INFO, e.getLocalizedMessage(), e); } catch (IOException e) {
LOGGER.log(Level.INFO, e.getLocalizedMessage(), e); } catch (IOException e) {
LOGGER.fine("Unable to parse Histogram:" + e.getLocalizedMessage());
LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } catch (IOException e) {
fOut.close(); } catch (FileNotFoundException e) { Log.d(TAG, e.getLocalizedMessage()); } catch (IOException e) { Log.d(TAG, e.getLocalizedMessage());
@Override public OutputStream receiveUpload(String filename, String mimeType) { File file = new File(pendingDir, filename); try { return new FileOutputStream(file); } catch (FileNotFoundException e) { logger.warn("Unable to create file '" + file + "': " + e.getLocalizedMessage()); return null; } } });