List of usage examples for java.io FileNotFoundException getMessage
public String getMessage()
From source file:ch.uzh.fabric.config.SampleStore.java
private Properties loadProperties() { Properties properties = new Properties(); try (InputStream input = new FileInputStream(file)) { properties.load(input);/*from www . j a v a 2s . com*/ input.close(); } catch (FileNotFoundException e) { LOGGER.warn(String.format("Could not find the file \"%s\"", file)); } catch (IOException e) { LOGGER.warn(String.format("Could not load keyvalue store from file \"%s\", reason:%s", file, e.getMessage())); } return properties; }
From source file:com.intel.ssg.dcst.panthera.cli.PantheraCliDriver.java
/** * Execute the cli work/*from w w w . j a v a 2 s. c o m*/ * @param ss CliSessionState of the CLI driver * @param conf HiveConf for the driver sionssion * @param oproc Opetion processor of the CLI invocation * @return status of the CLI comman execution * @throws Exception */ private int executeDriver(CliSessionState ss, HiveConf conf, OptionsProcessor oproc) throws Exception { // connect to Hive Server if (ss.getHost() != null) { ss.connect(); if (ss.isRemoteMode()) { prompt = "[" + ss.getHost() + ':' + ss.getPort() + "] " + prompt; char[] spaces = new char[prompt.length()]; Arrays.fill(spaces, ' '); prompt2 = new String(spaces); } } // CLI remote mode is a thin client: only load auxJars in local mode if (!ss.isRemoteMode() && !ShimLoader.getHadoopShims().usesJobShell()) { // hadoop-20 and above - we need to augment classpath using hiveconf // components // see also: code in ExecDriver.java ClassLoader loader = conf.getClassLoader(); String auxJars = HiveConf.getVar(conf, HiveConf.ConfVars.HIVEAUXJARS); if (StringUtils.isNotBlank(auxJars)) { loader = Utilities.addToClassPath(loader, StringUtils.split(auxJars, ",")); } conf.setClassLoader(loader); Thread.currentThread().setContextClassLoader(loader); } PantheraCliDriver cli = new PantheraCliDriver(); cli.setHiveVariables(oproc.getHiveVariables()); // use the specified database if specified cli.processSelectDatabase(ss); // Execute -i init files (always in silent mode) cli.processInitFiles(ss); if (ss.execString != null) { int cmdProcessStatus = cli.processLine(ss.execString); return cmdProcessStatus; } try { if (ss.fileName != null) { return cli.processFile(ss.fileName); } } catch (FileNotFoundException e) { System.err.println("Could not open input file for reading. (" + e.getMessage() + ")"); return 3; } ConsoleReader reader = getConsoleReader(); reader.setBellEnabled(false); // reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true))); for (Completor completor : getCommandCompletor()) { reader.addCompletor(completor); } String line; final String HISTORYFILE = ".hivehistory"; String historyDirectory = System.getProperty("user.home"); try { if ((new File(historyDirectory)).exists()) { String historyFile = historyDirectory + File.separator + HISTORYFILE; reader.setHistory(new History(new File(historyFile))); } else { System.err.println("WARNING: Directory for Hive history file: " + historyDirectory + " does not exist. History will not be available during this session."); } } catch (Exception e) { System.err.println("WARNING: Encountered an error while trying to initialize Hive's " + "history file. History will not be available during this session."); System.err.println(e.getMessage()); } int ret = 0; String prefix = ""; String curDB = getFormattedDb(conf, ss); String curPrompt = prompt + curDB; String dbSpaces = spacesForString(curDB); while ((line = reader.readLine(curPrompt + "> ")) != null) { if (!prefix.equals("")) { prefix += '\n'; } if (line.trim().endsWith(";") && !line.trim().endsWith("\\;")) { line = prefix + line; ret = cli.processLine(line, true); prefix = ""; curDB = getFormattedDb(conf, ss); curPrompt = prompt + curDB; dbSpaces = dbSpaces.length() == curDB.length() ? dbSpaces : spacesForString(curDB); } else { prefix = prefix + line; curPrompt = prompt2 + dbSpaces; continue; } } return ret; }
From source file:br.gov.jfrj.siga.ex.gsa.ExAdaptor.java
/** * Salva data no arquivo informado/*w ww .ja v a 2s . co m*/ * @param lastModified * @param path */ protected void saveLastModified(Date lastModified, String path) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); File lastModifiedFile = new File(path); if (lastModifiedFile.exists()) { lastModifiedFile.delete(); } String dateToSave = dateFormat.format(lastModified); try { FileOutputStream output = new FileOutputStream(lastModifiedFile); output.write(dateToSave.getBytes()); output.flush(); output.close(); } catch (FileNotFoundException e) { log.severe("Erro salvando arquivo no disco!"); log.info("verifique suas permisses e configuraes"); } catch (IOException e) { log.severe("Erro ao escrever no arquivo!"); log.severe("Erro: " + e.getMessage()); } }
From source file:io.sugo.grok.api.Grok.java
/** * Add patterns to {@code Grok} from the given file. * * @param file : Path of the grok pattern * @throws GrokException runtime expt/*from www.j a v a 2 s. c o m*/ */ public void addPatternFromFile(String file) throws GrokException { File f = new File(file); if (!f.exists()) { throw new GrokException("Pattern not found"); } if (!f.canRead()) { throw new GrokException("Pattern cannot be read"); } FileReader r = null; try { r = new FileReader(f); addPatternFromReader(r); } catch (FileNotFoundException e) { throw new GrokException(e.getMessage()); } catch (@SuppressWarnings("hiding") IOException e) { throw new GrokException(e.getMessage()); } finally { try { if (r != null) { r.close(); } } catch (IOException io) { // TODO(anthony) : log the error } } }
From source file:org.dataone.proto.trove.net.SocketFactoryManager.java
public SSLSocketFactory getSSLSocketFactory() throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException, KeyManagementException, CertificateException, IOException { // our return object log.debug("Enter getSSLSocketFactory"); SSLSocketFactory socketFactory = null; KeyStore keyStore = null;//from w w w . ja v a 2 s . c om // get the keystore that will provide the material // Catch the exception here so that the TLS connection scheme // will still be setup if the client certificate is not found. try { keyStore = getKeyStore(); } catch (FileNotFoundException e) { // these are somewhat expected for anonymous d1 client use log.warn( "Could not set up client side authentication - likely because the certificate could not be located: " + e.getMessage()); } // create SSL context SSLContext ctx = SSLContext.getInstance("TLS"); // use a very liberal trust manager for trusting the server // TODO: check server trust policy X509TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { log.info("checkClientTrusted - " + string); } public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { log.info("checkServerTrusted - " + string); } public X509Certificate[] getAcceptedIssuers() { log.info("getAcceptedIssuers"); return null; } }; // specify the client key manager KeyManager[] keyManagers = { new X509KeyManagerImpl(keyStore, keyStorePassword.toCharArray(), "cilogon") }; // KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); // keyManagerFactory.init(keyStore, keyStorePassword.toCharArray()); // keyManagers = keyManagerFactory.getKeyManagers(); // initialize the context ctx.init(keyManagers, new TrustManager[] { tm }, new SecureRandom()); socketFactory = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); return socketFactory; }
From source file:fr.paris.lutece.plugins.document.modules.metadatadublincore.business.DublinCoreMetadata.java
/** * Load dublin core metadata from an XML stream * @param strXmlData The XML content to get the attributes from *//*from w ww .j av a 2s . co m*/ public void load(String strXmlData) { // Configure Digester from XML ruleset URL rules = getClass().getResource(FILE_RULES); Digester digester = DigesterLoader.createDigester(rules); // Push empty List onto Digester's Stack digester.push(this); try { if (strXmlData != null) { StringReader sr = new StringReader(strXmlData); digester.parse(sr); } } catch (FileNotFoundException e) { AppLogService.error(e.getMessage(), e); } catch (SAXException e) { AppLogService.error(e.getMessage(), e); } catch (IOException e) { AppLogService.error(e.getMessage(), e); } }
From source file:me.mast3rplan.phantombot.script.Script.java
public void load() throws IOException { if (killed) { return;/*from w w w . j a v a 2s. c o m*/ } if (!file.getName().endsWith(".js")) { return; } /* Enable Error() in JS to provide an object with fileName and lineNumber. */ final ContextFactory ctxFactory = new ContextFactory() { @Override protected boolean hasFeature(Context cx, int featureIndex) { switch (featureIndex) { case Context.FEATURE_LOCATION_INFORMATION_IN_ERROR: return true; default: return super.hasFeature(cx, featureIndex); } } }; RhinoException.setStackStyle(StackStyle.MOZILLA); /* Create Debugger Instance - this opens for only init.js */ Main debugger = null; if (PhantomBot.enableRhinoDebugger) { if (file.getName().endsWith("init.js")) { debugger = new Main(file.getName()); debugger.attachTo(ctxFactory); } } context = ctxFactory.enterContext(); if (!PhantomBot.enableRhinoDebugger) { context.setOptimizationLevel(9); } ScriptableObject scope = context.initStandardObjects(global, false); scope.defineProperty("$", global, 0); scope.defineProperty("$api", ScriptApi.instance(), 0); scope.defineProperty("$script", this, 0); scope.defineProperty("$var", vars, 0); /* Configure debugger. */ if (PhantomBot.enableRhinoDebugger) { if (file.getName().endsWith("init.js")) { debugger.setBreakOnEnter(false); debugger.setScope(scope); debugger.setSize(640, 480); debugger.setVisible(true); } } try { context.evaluateString(scope, FileUtils.readFileToString(file), file.getName(), 1, null); } catch (FileNotFoundException ex) { throw new IOException("File not found. This could be a caching issue, will retry."); } catch (EvaluatorException ex) { throw new IOException("JavaScript Error: " + ex.getMessage()); } catch (Exception ex) { throw new IOException(ex.getMessage()); } }
From source file:ch.cyberduck.core.Local.java
public InputStream getInputStream() throws AccessDeniedException { try {//from w w w . ja v a2 s .co m return new LocalRepeatableFileInputStream(new File(path)); } catch (FileNotFoundException e) { throw new LocalAccessDeniedException(e.getMessage(), e); } }
From source file:ch.cyberduck.core.Local.java
public OutputStream getOutputStream(final boolean append) throws AccessDeniedException { try {/* ww w . j av a 2 s. co m*/ return new FileOutputStream(new File(path), append); } catch (FileNotFoundException e) { throw new LocalAccessDeniedException(e.getMessage(), e); } }
From source file:com.blackducksoftware.tools.commonframework.standard.email.CFEmailNotifier.java
private EmailTemplate generateEmail(ProjectPojo projectInfo, EmailContentMap map) { Reader reader = null;/* w ww . j av a 2 s. c o m*/ try { reader = new InputStreamReader(new FileInputStream(templateFileLocation)); } catch (FileNotFoundException e1) { log.error(e1.getMessage()); } VelocityContext velContext = initializeVelocityContext(projectInfo, map); EmailTemplate emailTemplate = evaluateVelocityContext(velContext, reader); try { reader.close(); } catch (IOException e) { log.error("Error closing reader", e); } return emailTemplate; }