List of usage examples for java.io FileNotFoundException FileNotFoundException
public FileNotFoundException(String s)
FileNotFoundException
with the specified detail message. From source file:calliope.db.MongoConnection.java
/** * Fetch a resource from the server, or try to. * @param collName the collection or database name * @param docID the path to the resource in the collection * @return the response as a string or null if not found *//* w w w . j ava 2 s. c o m*/ @Override public String getFromDb(String collName, String docID) throws AeseException { try { connect(); DBCollection coll = getCollectionFromName(collName); DBObject query = new BasicDBObject(JSONKeys.DOCID, docID); DBObject obj = coll.findOne(query); if (obj != null) return obj.toString(); else throw new FileNotFoundException("failed to find " + collName + "/" + docID); } catch (Exception e) { throw new AeseException(e); } }
From source file:fr.adfab.magebeans.processes.CreateModuleProcess.java
public void process() throws FileNotFoundException { if ("".equals(this.projectDir)) { throw new FileNotFoundException("Project directory not found"); }//from w w w . j a va 2s . c o m //Prepare some variables this.moduleName = this.company + "_" + this.module; this.moduleNameLower = this.moduleName.toLowerCase(); this.moduleDir = String.format(this.PATH_TEMP, this.projectDir, this.codePool, this.company, this.module); // Create config folder this._createFolders("etc"); this._createModuleXmlFile(); this._createConfigXml(); this._writeConfigXmlFile(); }
From source file:org.sakuli.starter.helper.SahiProxy.java
/** * Starts a seperate Thread for the sahi proxy. * You can do a shutdown with/* w ww .jav a 2 s.c o m*/ * * @param asyncron init if a separate thread should started * @throws SakuliInitException if the specified files in the sahi.properties are not valid */ public void startProxy(boolean asyncron) throws SakuliInitException, FileNotFoundException { sahiProxy = new Proxy(props.getProxyPort()); if (Files.exists(props.getSahiHomeFolder()) && Files.exists(props.getSahiConfigFolder())) { logger.info("START Sahi-PROXY: Sahi-Home folder '{}', Sahi-Configuration folder '{}'", props.getSahiHomeFolder().toAbsolutePath().toString(), props.getSahiConfigFolder().toAbsolutePath().toString()); try { injectCustomJavaScriptFiles(); //set the custom paths to the sahi environment Configuration.init(props.getSahiHomeFolder().toAbsolutePath().toString(), props.getSahiConfigFolder().toAbsolutePath().toString()); Configuration.setUnmodifiedTrafficLogging(false); Configuration.setModifiedTrafficLogging(false); //Starts the sahi proxy as asynchron Thread sahiProxy.start(asyncron); Thread.sleep(200); } catch (RuntimeException e) { logger.error("RUNTIME EXCEPTION"); throw new SakuliInitException(e); } catch (Throwable e) { logger.error("THROWABLE EXCEPTION"); throw new SakuliInitException(e.getMessage()); } } else { throw new FileNotFoundException("the path to '" + SahiProxyProperties.PROXY_HOME_FOLDER + "=" + props.getSahiHomeFolder().toAbsolutePath().toString() + "' or '" + SahiProxyProperties.PROXY_CONFIG_FOLDER + "=" + props.getSahiConfigFolder().toAbsolutePath().toString() + "' is not valid, please check the properties files!"); } }
From source file:gruifo.CmdOptions.java
private File getPath(final String path, final String option) throws FileNotFoundException { final File file = new File(path); if (!file.exists()) { throw new FileNotFoundException(path + " as supplied by -" + option + " does not exist. "); }/*ww w. jav a 2 s .c o m*/ return file; }
From source file:cz.autoclient.league_of_legends.DataLoader.java
public static JSONArray arrayFromFile(File file) throws FileNotFoundException { String data = stringFromFile(file); //System.out.println("JSON from file:\n"+result); try {/*from www. j ava 2 s . c om*/ return new JSONArray(data); } 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:org.cfr.commons.util.log.Log4jConfigurer.java
/** * Initialize log4j from the given location, with the given refresh interval * for the config file. Assumes an XML file in case of a ".xml" file extension, * and a properties file otherwise.// w w w . jav a 2 s. c o m * <p>Log4j's watchdog thread will asynchronously check whether the timestamp * of the config file has changed, using the given interval between checks. * A refresh interval of 1000 milliseconds (one second), which allows to * do on-demand log level changes with immediate effect, is not unfeasible. * <p><b>WARNING:</b> Log4j's watchdog thread does not terminate until VM shutdown; * in particular, it does not terminate on LogManager shutdown. Therefore, it is * recommended to <i>not</i> use config file refreshing in a production J2EE * environment; the watchdog thread would not stop on application shutdown there. * @param location the location of the config file: either a "classpath:" location * (e.g. "classpath:myLog4j.properties"), an absolute file URL * (e.g. "file:C:/log4j.properties), or a plain absolute path in the file system * (e.g. "C:/log4j.properties") * @param refreshInterval interval between config file refresh checks, in milliseconds * @throws FileNotFoundException if the location specifies an invalid file path */ public static void initLogging(String location, long refreshInterval) throws FileNotFoundException { // String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location); String resolvedLocation = location; File file = ResourceUtils.getFile(resolvedLocation); if (!file.exists()) { throw new FileNotFoundException("Log4j config file [" + resolvedLocation + "] not found"); } if (resolvedLocation.toLowerCase().endsWith(XML_FILE_EXTENSION)) { DOMConfigurator.configureAndWatch(file.getAbsolutePath(), refreshInterval); } else { PropertyConfigurator.configureAndWatch(file.getAbsolutePath(), refreshInterval); } }
From source file:edu.odu.cs.cs350.yellow1.jar.JarUtil.java
/** * Look for the existence of the origin and target directories * if create Target Directory is set to true this method will create the target directory if it does not * exist/*from w w w. java 2s. co m*/ * @return true if both origin and target exist or if origin exists and target is created otherwise * @throws FileNotFoundException if the origin and target do not exist */ public boolean setUp() throws FileNotFoundException { if (!origin.exists()) throw new FileNotFoundException( "Jar Util The origin direcory does not exists path= " + origin.getAbsolutePath()); if (!origin.isDirectory()) throw new FileNotFoundException( "Jar Util The origin direcory is not a directory at all path= " + origin.getAbsolutePath()); if (targetState.equals(TargetHandleingState.createTarget)) { if (!target.exists()) return target.mkdir(); } else { if (!target.exists()) throw new FileNotFoundException( "Jar Util The target direcory does not exists path= " + target.getAbsolutePath()); if (!target.isDirectory()) throw new FileNotFoundException( "Jar Util The target direcory is not a directory at all path= " + target.getAbsolutePath()); } return true; }
From source file:com.hpl.erk.files.StreamDecompressor.java
@SuppressWarnings("resource") public static InputStream decompress(File file) throws IOException { StreamDecompressor decompressor = null; final String infileName = file.getName(); if (file.exists()) { int longestLength = 0; for (String ext : decompressors.keySet()) { final int len = ext.length(); if (len > longestLength && infileName.endsWith(ext)) { decompressor = decompressors.get(ext); longestLength = len;/* w w w. j a va 2s. c om*/ } } if (decompressor == null) { decompressor = UNCOMPRESSED; } } else { final File infileParent = file.getParentFile(); for (String ext : decompressors.keySet()) { File f = new File(infileParent, infileName + ext); if (f.exists()) { decompressor = decompressors.get(ext); file = f; break; } } if (decompressor == null) { throw new FileNotFoundException(String.format( "File not found: %s (or with any of %s). Use %s.register() to add more compression schemes.", file, decompressors.keySet(), StreamDecompressor.class.getSimpleName())); } } InputStream s = new FileInputStream(file); s = decompressor.decompress(s); return s; }
From source file:info.novatec.testit.livingdoc.agent.server.AgentConfiguration.java
private Properties loadProperties(String config) throws IOException { Properties properties = new Properties(); if (config == null) { File configFile = new File(DEFAULT_CONFIG_FILE); if (configFile.exists()) { loadProperties(properties, configFile); } else {//from w w w . ja v a2 s . co m log.info("Default configuration file not found. Skip."); } } else { File configFile = new File(config); if (!configFile.exists()) { throw new FileNotFoundException( String.format("Configuration file '%s' does not exist", configFile.getAbsolutePath())); } loadProperties(properties, configFile); } return properties; }
From source file:edu.odu.cs.cs350.yellow1.ant.AntRunner.java
/** * Discover the build file and set up project execution * @throws BuildFileNotFoundException/*w w w . j av a 2 s .co m*/ * @throws FileNotFoundException */ public void setUp() throws BuildFileNotFoundException, FileNotFoundException { if (!projectFolder.isDirectory()) throw new FileNotFoundException( "The project folder " + projectFolder.getName() + " is not a directory"); for (File f : projectFolder.listFiles(ff)) { System.out.println(f.getName()); if (f.getName().equals("build.xml")) buildFile = f; break; } if (buildFile == null) throw new BuildFileNotFoundException( "The build file for project at: " + projectFolder.getAbsolutePath() + " can not be found"); antProject = new Project(); antProject.init(); antProject.setUserProperty("ant.file", buildFile.getAbsolutePath()); projectHelp = ProjectHelper.getProjectHelper(); antProject.addReference("ant.projectHelper", projectHelp); projectHelp.parse(antProject, buildFile); targets = antProject.getTargets(); if (displayOutPut) { consoleLogger = new DefaultLogger(); consoleLogger.setErrorPrintStream(System.err); consoleLogger.setOutputPrintStream(System.out); consoleLogger.setMessageOutputLevel(Project.MSG_INFO); antProject.addBuildListener(consoleLogger); } if (requiresInit) antProject.executeTarget(targets.get("init").getName()); }