List of usage examples for java.io FileNotFoundException FileNotFoundException
public FileNotFoundException(String s)
FileNotFoundException
with the specified detail message. From source file:net.owl_black.vmgparser.VmgParser.java
public VmgParser(File f, String encoding) throws UnsupportedEncodingException, FileNotFoundException { if (f == null) throw new NullPointerException("Given file is null"); if (!f.exists()) throw new FileNotFoundException("Provided VMG file does not exist."); lexer = new VmgLexer(f, encoding); env_stack = new Stack<String>(); opt_stack = new Stack<String>(); //Initialize the list of Date parser. }
From source file:com.ottogroup.bi.spqr.websocket.server.SPQRWebSocketServer.java
/** * Initializes and executes the server components * @param configurationFile reference to configuration file * @throws IOException/* www.ja v a 2 s .c o m*/ * @throws InterruptedException */ protected void run(final String configurationFile) throws IOException, InterruptedException { /////////////////////////////////////////////////////////////////// // lookup configuration file and create handle File cfgFile = new File(StringUtils.trim(configurationFile)); if (!cfgFile.isFile()) throw new FileNotFoundException("No configuration file found at '" + configurationFile + "'"); // /////////////////////////////////////////////////////////////////// run(new FileInputStream(cfgFile)); }
From source file:cz.autoclient.league_of_legends.DataLoader.java
public static JSONObject fromFile(File file) throws FileNotFoundException { char[] buff = new char[(int) file.length()]; try {//w w w. j a v a 2 s. c om (new FileReader(file)).read(buff); } catch (IOException e) { throw new FileNotFoundException("Invalid file."); } String result = new StringBuilder().append(buff).toString(); //System.out.println("JSON from file:\n"+result); try { return new JSONObject(result); } catch (JSONException ex) { throw new FileNotFoundException("Invalid file contents - \n JSON error:" + ex); //Logger.getLogger(DataLoader.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.ethlo.geodata.util.ResourceUtil.java
private Resource openConnection(String urlStr) throws IOException { final String[] urlParts = StringUtils.split(urlStr, "|"); if (urlStr.startsWith("file:")) { String path = urlParts[0].substring(7); if (path.startsWith("~" + File.separator)) { path = System.getProperty("user.home") + path.substring(1); }//from w w w. j a v a 2 s. c om final File file = new File(path); if (!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath()); } return new FileSystemResource(file); } else if (urlStr.startsWith("classpath:")) { return new ClassPathResource(urlParts[0].substring(10)); } return new UrlResource(urlParts[0]); }
From source file:com.greenpepper.server.license.LicenceGenerator.java
private static LicenseParam getLicenseParam() { final KeyStoreParam privateKeyStoreParam = new KeyStoreParam() { public InputStream getStream() throws IOException { final String resourceName = "privateKeys.store"; final InputStream in = getClass().getResourceAsStream(resourceName); if (in == null) throw new FileNotFoundException(resourceName); return in; }/*ww w. ja va2s. c o m*/ public String getAlias() { return "privatekey"; } public String getStorePwd() { return "gr33np3pp3r"; } public String getKeyPwd() { return getStorePwd(); } }; final CipherParam cipherParam = new CipherParam() { public String getKeyPwd() { return "gr33np3pp3r"; } }; final LicenseParam licenseParam = new LicenseParam() { public String getSubject() { return "GreenPepper"; } public Preferences getPreferences() { return Preferences.userNodeForPackage(LicenceGenerator.class); } public KeyStoreParam getKeyStoreParam() { return privateKeyStoreParam; } public CipherParam getCipherParam() { return cipherParam; } }; return licenseParam; }
From source file:com.jkoolcloud.tnt4j.streams.configure.StreamsConfigLoader.java
/** * Constructs a new TNT4J-Streams Configuration loader, using the default configuration file * ({@value #DFLT_CFG_FILE_NAME}), which is assumed to be in the classpath. * * @throws SAXException//from ww w.j av a2 s . c o m * if there was an error parsing the file * @throws ParserConfigurationException * if there is an inconsistency in the configuration * @throws IOException * if there is an error reading the file */ public StreamsConfigLoader() throws SAXException, ParserConfigurationException, IOException { InputStream config; String cfgPath = System.getProperty(STREAMS_CONFIG_KEY); if (StringUtils.isNotEmpty(cfgPath)) { config = openCfgFile(cfgPath); if (config == null) { throw new FileNotFoundException(StreamsResources.getStringFormatted( StreamsResources.RESOURCE_BUNDLE_NAME, "StreamsConfig.file.not.found", cfgPath)); } } else { config = openCfgFile(DFLT_CONFIG_FILE_PATH); if (config == null) { config = openCfgFile(DFLT_CONFIG_FILE_PATH2); } if (config == null) { throw new FileNotFoundException( StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "StreamsConfig.files.not.found", DFLT_CONFIG_FILE_PATH, DFLT_CONFIG_FILE_PATH2)); } } load(config); }
From source file:io.wcm.caravan.pipeline.impl.JsonPipelineOutputTest.java
@Test public void plainPipelineTransportError() { // tests that errors from the transport layers are properly handled FileNotFoundException ex = new FileNotFoundException("Failed"); JsonPipeline pipeline = newPipelineWithResponseError(ex); pipeline.getStringOutput().subscribe(stringObserver); // make sure that only #onError was called, with the FileNotFoundException thrown from the transport layer pipeline.getStringOutput().subscribe(new ExceptionExpectingObserver(ex)); verifyNoMoreInteractions(cacheAdapter); }
From source file:mitm.common.security.keystore.KeyStoreLoader.java
public KeyStore loadKeyStore(File file, char[] password) throws IOException, KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, CertificateException { if (file == null) { throw new IOException("file cannot be null"); }//from w ww .ja va 2 s. c o m if (!file.exists()) { throw new FileNotFoundException("file does not exist"); } if (StringUtils.isEmpty(keyStoreType)) { determineKeyStoreTypeFromFile(file); } KeyStore keyStore = KeyStore.getInstance(keyStoreType); InputStream input = new FileInputStream(file); try { keyStore.load(input, password); } finally { IOUtils.closeQuietly(input); } return keyStore; }
From source file:ru.histone.spring.mvc.HistoneView.java
@Override public boolean checkResource(Locale locale) throws Exception { try {//from ww w . j a v a2 s . c o m Reader content = new InputStreamReader(getServletContext().getResourceAsStream(getUrl())); if (content == null) { throw new FileNotFoundException("Can't find view file"); } getHistone().setGlobalProperty(GlobalProperty.BASE_URI, "webapp:" + getUrl()); getHistone().evaluate(content); return true; } catch (FileNotFoundException ex) { if (logger.isDebugEnabled()) { logger.debug("No Histone view found for URL: " + getUrl()); } return false; } catch (HistoneException ex) { throw new ApplicationContextException("Failed to parse Histone template for URL [" + getUrl() + "]", ex); } catch (IOException ex) { throw new ApplicationContextException("Could not load Histone template for URL [" + getUrl() + "]", ex); } }
From source file:com.yifanlu.PSXperiaTool.Extractor.CrashBandicootExtractor.java
private void verifyFiles() throws IOException { nextStep("Verifying files"); if (!mApkFile.exists()) throw new FileNotFoundException("Cannot find APK file: " + mApkFile.getPath()); if (!mZpakData.exists()) throw new FileNotFoundException("Cannot find ZPAK file: " + mZpakData.getPath()); if (!mOutputDir.exists()) mOutputDir.mkdirs();//from ww w .j av a 2 s. c o m if (mOutputDir.list().length > 0) Logger.warning( "The output directory is not empty! Whatever is in this folder will be included in all generated APKs."); //FileUtils.cleanDirectory(mOutputDir); }