List of usage examples for java.io FileNotFoundException FileNotFoundException
public FileNotFoundException(String s)
FileNotFoundException
with the specified detail message. From source file:com.github.nbyl.xfdcontrol.service.Application.java
private static void installConfigLocation() throws FileNotFoundException { if (Strings.isNullOrEmpty(System.getProperty(SPRING_CONFIG_LOCATION))) { File configFile = new File(StandardSystemProperty.USER_HOME.value(), ".xfdcontrol.properties"); LOGGER.debug("Loading configuration from file {}.", configFile.getAbsolutePath()); if (!configFile.exists()) { throw new FileNotFoundException("Config file " + configFile.getPath() + " does not exist."); }/* www .j a v a 2 s . c o m*/ System.setProperty(SPRING_CONFIG_LOCATION, configFile.getAbsolutePath()); } else { LOGGER.debug("Configuration location already set."); } }
From source file:hd3gtv.mydmam.useraction.fileoperation.CopyMove.java
public static void checkExistsCanRead(File element) throws IOException, NullPointerException { if (element == null) { throw new NullPointerException("element is null"); }/*from ww w .j a va2s .c o m*/ if (element.exists() == false) { throw new FileNotFoundException("\"" + element.getPath() + "\" in filesytem"); } if (element.canRead() == false) { throw new IOException("Can't read element \"" + element.getPath() + "\""); } }
From source file:com.dsclab.loader.export.Configs.java
public Configs(String propFileName) throws IOException { try {/*from w w w .ja v a2 s .c o m*/ inputStream = getClass().getClassLoader().getResourceAsStream(propFileName); if (inputStream != null) { prop.load(inputStream); } else { throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); } } catch (Exception e) { LOG.error(e); } finally { inputStream.close(); } }
From source file:de.unigoettingen.sub.search.opac.ConfigOpac.java
private static XMLConfiguration getConfig() throws FileNotFoundException { if (Objects.nonNull(config)) { return config; }/*ww w . j a v a 2 s.c o m*/ KitodoConfigFile opacConfiguration = KitodoConfigFile.OPAC_CONFIGURATION; if (!opacConfiguration.exists()) { throw new FileNotFoundException("File not found: " + opacConfiguration.getAbsolutePath()); } try { config = new XMLConfiguration(opacConfiguration.getFile()); } catch (ConfigurationException e) { logger.error(e.getMessage(), e); config = new XMLConfiguration(); } config.setListDelimiter('&'); config.setReloadingStrategy(new FileChangedReloadingStrategy()); return config; }
From source file:com.funambol.rhinounit.RhinoUnitLoader.java
/** * Returns a script containing the entire RhinoUnit framework. * Single RhinoUnit scripts are loaded from the classpath so that the * framework can be easily used simply adding the jar in the classpath * * @return the RhinoUnit framework in a single script * * @throws IOException if the framework could not be loaded from classpath *//* w w w .j a v a 2 s . com*/ public static String getRhinoUnit() throws IOException { StringBuffer ret = new StringBuffer(); InputStream is = null; for (int i = 0; i < SCRIPTS.length; ++i) { try { is = RhinoUnitLoader.class.getResourceAsStream(SCRIPTS[i]); if (is == null) { throw new FileNotFoundException("Resource " + SCRIPTS[i] + " not found in classpath"); } ret.append(IOUtils.toString(is)).append("\n\n"); } finally { if (is != null) { is.close(); } } } return ret.toString(); }
From source file:com.tc.config.Directories.java
/** * Get installation root directory.//w ww .j a v a 2 s . c om * * @return Installation root directory or null if TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME is set and * TC_INSTALL_ROOT_PROPERTY_NAME is not. * @throws FileNotFoundException If {@link #TC_INSTALL_ROOT_PROPERTY_NAME} has not been set. If * {@link #TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME} has not been set, this exception may be thrown if the * installation root directory has not been set, is not a directory */ public static File getInstallationRoot() throws FileNotFoundException { boolean ignoreCheck = Boolean.getBoolean(TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME); if (ignoreCheck) { // XXX hack to have enterprise system tests to find license key under <ee-branch>/code/base String baseDir = System.getProperty("tc.base-dir"); return new File(baseDir != null ? baseDir : ".", "../../../code/base"); } else { String path = System.getProperty(TC_INSTALL_ROOT_PROPERTY_NAME); if (StringUtils.isBlank(path)) { // formatting throw new FileNotFoundException("The system property '" + TC_INSTALL_ROOT_PROPERTY_NAME + "' has not been set. As such, the Terracotta installation directory cannot be located."); } File rootPath = new File(path).getAbsoluteFile(); if (!rootPath.isDirectory()) { // formatting throw new FileNotFoundException("The specified Terracotta installation directory, '" + rootPath + "', located via the value of the system property '" + TC_INSTALL_ROOT_PROPERTY_NAME + "', does not actually exist."); } return rootPath; } }
From source file:brut.util.Jar.java
public static File extractToTmp(String resourcePath, String tmpPrefix) throws BrutException { try {/* w ww . ja v a 2s .c o m*/ InputStream in = Class.class.getResourceAsStream(resourcePath); if (in == null) { throw new FileNotFoundException(resourcePath); } File fileOut = File.createTempFile(tmpPrefix, null); fileOut.deleteOnExit(); OutputStream out = new FileOutputStream(fileOut); IOUtils.copy(in, out); in.close(); out.close(); return fileOut; } catch (IOException ex) { throw new BrutException("Could not extract resource: " + resourcePath, ex); } }
From source file:com.splunk.shuttl.archiver.model.LocalBucket.java
private static File verifyDirectory(File directory) throws FileNotFoundException, FileNotDirectoryException { if (!directory.exists()) throw new FileNotFoundException("Could not find directory: " + directory); else if (!directory.isDirectory()) throw new FileNotDirectoryException("Directory " + directory + " is not a directory"); else/* ww w . ja va 2s .co m*/ return directory; }
From source file:com.sarm.Travelogue.process.DestinationProcessorRegressorTest.java
@BeforeClass public static void setUpClass() { logger.info("DestinationProcessorRegressorTest Commencing loading test properties ..."); Properties prop = new Properties(); String propFileName = LonelyConstants.testPropertyFile; try (InputStream input = new FileInputStream(propFileName)) { if (input == null) { logger.debug("input Stream for test.properties file : is Null "); throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); }/* w w w.j a v a2 s . com*/ logger.debug("Loading properties file " + propFileName); prop.load(input); } catch (FileNotFoundException ex) { logger.debug("FileNotFoundException " + propFileName); ex.printStackTrace(); } catch (IOException ex) { logger.debug("IOException " + propFileName); ex.printStackTrace(); } regressDestinationfile = prop.getProperty(LonelyConstants.regressDestinationfile); try { testMarshall(".//destinations.xml"); } catch (JAXBException | FileNotFoundException | XMLStreamException | UnsupportedEncodingException ex) { ex.printStackTrace(); } }
From source file:com.stratio.mojo.scala.crossbuild.ITs.java
public static boolean verify(final List<String> scalaBinaryVersions, final List<String> artifactNames, final List<String> targetPaths, final List<String> testCases) throws IOException, FileNotFoundException { if (artifactNames.size() != targetPaths.size()) { throw new IllegalArgumentException("artifactNames and modulePaths must be equal size"); }/*from w w w . j a va 2 s. co m*/ if (scalaBinaryVersions.isEmpty()) { throw new IllegalArgumentException("At least one scalaBinaryVersion must be provided"); } for (final String scalaBinaryVersion : scalaBinaryVersions) { for (int i = 0; i < artifactNames.size(); i++) { final String artifactName = artifactNames.get(i); final String artifactId = artifactName + "_" + scalaBinaryVersion; final File targetPath = new File(targetPaths.get(i)); final File targetScalaPath = new File(targetPath, scalaBinaryVersion); final File artifactPath = new File(targetScalaPath, artifactId + "-1.jar"); if (!artifactPath.isFile()) { throw new FileNotFoundException("Could not find generated artifact: " + artifactPath); } if (testCases.isEmpty()) { continue; } final File surefireReportsPath = new File(targetScalaPath, "surefire-reports"); if (!surefireReportsPath.isDirectory()) { throw new FileNotFoundException( "Could not find surefire-reports directory: " + surefireReportsPath); } final File[] testReports = surefireReportsPath.listFiles(new FileFilter() { @Override public boolean accept(final File pathname) { return pathname.getName().endsWith(".xml") && pathname.getName().startsWith("TEST-"); } }); if (testReports.length == 0) { throw new FileNotFoundException("Could not find test reports"); } for (final String testCase : testCases) { final String scalaString = "[Scala " + scalaBinaryVersion + "]"; boolean found = false; for (final File testReport : testReports) { final String testReportString = IOUtils.toString(new FileInputStream(testReport)); final String testCaseWithSuffix = testCase + " " + scalaString; if (testReportString.contains(testCaseWithSuffix)) { found = true; break; } } if (!found) { throw new RuntimeException("JUnit XML test report does not contain Scala version string (" + scalaString + ")"); } } } } return true; }