List of usage examples for java.io FileNotFoundException FileNotFoundException
public FileNotFoundException(String s)
FileNotFoundException
with the specified detail message. From source file:de.xwic.sandbox.server.installer.XmlImport.java
/** * @param file//from w w w. j a v a 2 s . c o m * @throws ConfigurationException */ public void importFile(File file) throws IOException, DocumentException, ConfigurationException { if (!file.exists()) { throw new FileNotFoundException("File not found: " + file.getName()); } log.info("Importing " + file.getName()); Document doc = new SAXReader().read(file); Element root = doc.getRootElement(); String type = root.attributeValue("type"); if (type != null && "security".equals(type)) { importAll(root.element(XmlExport.ELM_DATA)); } else if (type != null && "entities".equals(type)) { importAll(root.element(XmlExport.ELM_DATA)); } else if (type != null && "picklists".equals(type)) { importPicklists(root.element(XmlExport.ELM_DATA)); } else if ("config".equals(root.getName())) { importConfig(root); } }
From source file:com.igormaznitsa.j2z80.utils.Utils.java
/** * Read a text (UTF-8 encoded) resource in a class path of a class * @param thisClass the class to be used to get a class path, must not be null * @param resource the resource name, must not be null * @return the loaded text as a solid string * @throws IOException it will be thrown if there is any transport error * @throws FileNotFoundException it will be thrown if the resource is not found *//*from www. j ava2 s. c o m*/ public static String readTextResource(final Class<?> thisClass, final String resource) throws IOException { final InputStream file = thisClass.getResourceAsStream(resource); if (file == null) { throw new FileNotFoundException("Can't find resource " + resource); } final StringBuilder builder = new StringBuilder(); final BufferedReader reader = new BufferedReader(new InputStreamReader(file, "UTF-8")); try { while (true) { final String line = reader.readLine(); if (line == null) { break; } builder.append(line).append(NEXT_LINE); } return builder.toString(); } finally { silentlyClose(reader); } }
From source file:de.tuebingen.uni.sfs.germanet.api.WiktionaryLoader.java
/** * Loads <code>WiktionaryParaphrases</code> from the specified file into this * <code>WiktionaryLoader</code>'s <code>GermaNet</code> object. * @param wiktionaryFile the file containing <code>WiktionaryParaphrases</code> data * @throws java.io.FileNotFoundException * @throws javax.xml.stream.XMLStreamException *///w w w. j a v a 2s.co m protected void loadWiktionary(File wiktionaryFile) throws FileNotFoundException, XMLStreamException { wikiDir = wiktionaryFile; FilenameFilter filter = new WikiFilter(); //get only wiktionary files File[] wikiFiles = wikiDir.listFiles(filter); if (wikiFiles == null || wikiFiles.length == 0) { throw new FileNotFoundException( "Unable to load Wiktionary Paraphrases from \"" + this.wikiDir.getPath() + "\""); } for (File wikiFile : wikiFiles) { logger.debug("Loading " + wikiFile.getName() + "..."); InputStream in = new FileInputStream(wikiFile); XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader parser = factory.createXMLStreamReader(in); int event; String nodeName; //Parse entire file, looking for Wiktionary paraphrase start elements while (parser.hasNext()) { event = parser.next(); switch (event) { case XMLStreamConstants.START_DOCUMENT: namespace = parser.getNamespaceURI(); break; case XMLStreamConstants.START_ELEMENT: nodeName = parser.getLocalName(); if (nodeName.equals(GermaNet.XML_WIKTIONARY_PARAPHRASE)) { WiktionaryParaphrase wiki = processWiktionaryParaphrase(parser); germaNet.addWiktionaryParaphrase(wiki); } break; } } parser.close(); } logger.debug("Done."); }
From source file:com.infosupport.ellison.core.archive.ApplicationArchive.java
/** * Constructor./*from w w w . j av a 2s.c om*/ * <p/> * Please note that this constructor immediately tries to unpack the supplied archive, and throws an exception when * it doesn't succeed. * * @param applicationFile * the application archive file to use * * @throws IOException * when there was an error unpacking the application archive. Specifically, a {@link FileNotFoundException} is * thrown if {@code applicationFile} does not point to an existing file. */ public ApplicationArchive(File applicationFile) throws IOException { if (!applicationFile.exists()) { throw new FileNotFoundException( String.format("File does not exist: %s", applicationFile.getAbsolutePath())); } this.applicationFile = applicationFile; unpackJar(); }
From source file:com.linkedin.pinot.core.data.readers.AvroRecordReader.java
@Override public void init() throws Exception { final File file = new File(_fileName); if (!file.exists()) { throw new FileNotFoundException("File is not existed!"); }// ww w . ja va 2s. co m //_schemaExtractor = FieldExtractorFactory.get(_dataReaderSpec); if (_fileName.endsWith("gz")) { _dataStream = new DataFileStream<GenericRecord>(new GZIPInputStream(new FileInputStream(file)), new GenericDatumReader<GenericRecord>()); } else { _dataStream = new DataFileStream<GenericRecord>(new FileInputStream(file), new GenericDatumReader<GenericRecord>()); } }
From source file:com.valco.utility.FacturasUtility.java
private static byte[] getBytesPrivateKey(String directorio) throws Exception { try (InputStream inputstream = new FileInputStream(directorio);) { return getBytes(inputstream); } catch (FileNotFoundException ex) { throw new FileNotFoundException("No se encuentra la llave privada en el " + "directorio especificado"); } catch (IOException iOE) { throw new IOException("Ocurri un error al leer el archivo con la llave"); }//w ww . j a va 2 s .co m }
From source file:com.ariatemplates.attester.junit.AttesterProcess.java
public AttesterProcess(String... cmd) { try {//from ww w . j a v a2s . c o m String path = System.getProperty(ATTESTER_PATH_SYS_PROPERTY); if (path == null) { throw new ExternalProcessException(MISSING_SYS_PROPERTY); } File jsFile = new File(path, PATH_IN_ATTESTER_DIRECTORY); String[] newCmd = new String[cmd.length + 2]; newCmd[0] = jsFile.getAbsolutePath(); if (!jsFile.exists()) { throw new ExternalProcessException( String.format(INVALID_PATH_IN_SYS_PROPERTY, path, new FileNotFoundException(newCmd[0]))); } newCmd[1] = "-j"; // JSON output System.arraycopy(cmd, 0, newCmd, 2, cmd.length); nodeProcess = ExternalProcess.node.run(newCmd); StreamRedirector.redirectStream(nodeProcess.getErrorStream(), System.out); inputMessages = new JsonInputStream(nodeProcess.getInputStream()); checkCompatibility(); } catch (RuntimeException e) { checkProcessEnded(); throw e; } }
From source file:com.seedboxer.seedboxer.mule.processor.DownloadReceiver.java
private void processDownload(Message msg, DownloadQueueItem item) throws FileNotFoundException { String downloadPath = item.getDownload(); File toUpload = new File(downloadPath); if (!toUpload.exists()) { throw new FileNotFoundException("File " + downloadPath + " doesn't exists."); }/*from w w w. j a va 2 s.c om*/ String fileName = toUpload.getName(); msg.setHeader(Configuration.FILES, Collections.singletonList(downloadPath)); msg.setHeader(Configuration.FILES_NAME, Collections.singletonList(fileName)); }
From source file:net.seedboxer.mule.processor.DownloadReceiver.java
private void processDownload(Message msg, DownloadQueueItem item) throws IOException { String downloadPath = item.getDownload(); File toUpload = new File(downloadPath); if (!toUpload.exists()) { throw new FileNotFoundException("File " + downloadPath + " doesn't exists."); }/* ww w. ja v a2 s .c om*/ String fileName = toUpload.getName(); msg.setHeader(Configuration.FILE, downloadPath); msg.setHeader(Configuration.FILE_NAME, fileName); msg.setHeader(Exchange.FILE_NAME, fileName); msg.setBody(toUpload); sessionManager.addSession(item.getUser().getId(), fileName, FileUtils.calculateSize(toUpload)); }
From source file:com.aceevo.ursus.config.UrsusConfigurationFactory.java
private InputStream open(String configurationFile) throws IOException { final File file = new File(configurationFile); if (!file.exists()) { throw new FileNotFoundException("File " + file + " not found"); }// www. ja v a 2 s . com return new FileInputStream(file); }