List of usage examples for java.io FileNotFoundException FileNotFoundException
public FileNotFoundException(String s)
FileNotFoundException
with the specified detail message. From source file:onl.area51.filesystem.http.client.HttpUtils.java
public static void send(char[] path, Function<char[], String> remoteUri, Function<char[], Path> getPath, Supplier<String> userAgent) throws IOException { if (path == null || path.length == 0) { throw new FileNotFoundException("/"); }//from ww w . java2 s .c o m String uri = remoteUri.apply(path); if (uri != null) { HttpEntity entity = new PathEntity(getPath.apply(path)); LOG.log(Level.FINE, () -> "Sending " + uri); HttpPut put = new HttpPut(uri); put.setHeader(USER_AGENT, userAgent.get()); put.setEntity(entity); try (CloseableHttpClient client = HttpClients.createDefault()) { try (CloseableHttpResponse response = client.execute(put)) { int returnCode = response.getStatusLine().getStatusCode(); LOG.log(Level.FINE, () -> "ReturnCode " + returnCode + ": " + response.getStatusLine().getReasonPhrase()); } } } }
From source file:libepg.epg.section.SectionLoader.java
public Map<Integer, List<Section>> load() throws FileNotFoundException { //??/*from ww w . j a va2 s. c o m*/ if (!tsFile.isFile()) { throw new FileNotFoundException( "???? = " + tsFile.getAbsolutePath()); } LOG.info("?? = " + tsFile.getAbsolutePath()); final TsReader reader = new TsReader(tsFile, pids, readLimit); Map<Integer, List<TsPacketParcel>> pid_packets = reader.getPackets(); Map<Integer, List<Section>> pids_sections_temp = new ConcurrentHashMap<>(); for (Integer pidKey : pid_packets.keySet()) { LOG.info("?pid = " + Integer.toHexString(pidKey) + " pid = " + RESERVED_PROGRAM_ID.reverseLookUp(pidKey)); SectionReconstructor sectionMaker = new SectionReconstructor(pid_packets.get(pidKey), pidKey); List<Section> sections = sectionMaker.getSections(); if (sections != null) { LOG.info(" = " + sections.size()); pids_sections_temp.put(pidKey, sections); } } return Collections.unmodifiableMap(pids_sections_temp); }
From source file:fm.last.moji.local.LocalMojiFile.java
@Override public InputStream getInputStream() throws IOException { if (!file.exists()) { throw new FileNotFoundException(file.getCanonicalPath()); }/*from w w w . ja v a 2s. c o m*/ return new FileInputStream(file); }
From source file:edu.cornell.med.icb.goby.reads.PicardFastaIndexedSequence.java
public PicardFastaIndexedSequence(final String filename) throws FileNotFoundException { delegate = new IndexedFastaSequenceFile(new File(filename)); indexDelegate = new FastaSequenceIndex(new File(filename + ".fai")); final int numContigs = indexDelegate.size(); if (!delegate.isIndexed()) throw new FileNotFoundException("An fasta idx index must be found for filename " + filename); lengths = new int[numContigs]; names = new String[numContigs]; basesPerLine = new long[numContigs]; final LineIterator lineIt = new LineIterator(new FileReader(filename + ".fai")); // collect the contig names by parsing the text fai file. For some bizarre reason neither the // IndexedFastaSequenceFile class nor the FastaSequenceIndex class expose the contig names, yet // contig name is the parameter expected to get data from the sequences! int index = 0; while (lineIt.hasNext()) { final String line = lineIt.nextLine(); final String[] tokens = line.split("[\\s]"); names[index] = tokens[0];//from w w w . ja v a 2 s . co m namesToIndices.put(tokens[0], index); lengths[index] = Integer.parseInt(tokens[1]); basesPerLine[index] = Long.parseLong(tokens[2]); index++; } }
From source file:io.hops.security.HopsUtil.java
/** * Read password for cryptographic material from a file. The file could be * either localized in a container or from Hopsworks certificates transient * directory.//ww w .j a v a 2s . c o m * @param passwdFile Location of the password file * @return Password to unlock cryptographic material * @throws IOException */ public static String readCryptoMaterialPassword(File passwdFile) throws IOException { if (!passwdFile.exists()) { throw new FileNotFoundException("File containing crypto material " + "password could not be found"); } return FileUtils.readFileToString(passwdFile).trim(); }
From source file:com.walmartlabs.mupd8.application.Config.java
public Config(File directory) throws IOException { File[] files = directory.listFiles(new FilenameFilter() { @Override//from ww w . j a v a 2s. c om public boolean accept(File dir, String name) { return name.endsWith(".cfg"); } }); if (files == null) { throw new FileNotFoundException("Configuration path " + directory.toString() + " is not a directory."); } Arrays.sort(files, new Comparator<File>() { @Override public int compare(File o1, File o2) { return o1.getName().compareTo(o2.getName()); } }); applyFiles(configuration, files); workerJSONs = extractWorkerJSONs(configuration); }
From source file:$.LogParser.java
public File[] getLogFiles(final DateTime date) throws FileNotFoundException { File logFolder = new File(logFolderPath); if (!logFolder.exists() || !logFolder.canRead()) { throw new FileNotFoundException("there is no readable log folder - " + logFolderPath); }/*from ww w. j a v a 2 s . c o m*/ final String logDateFormatted = FILE_DATE_FORMAT.print(date); final long dateMillis = date.getMillis(); File[] files = logFolder.listFiles(new FileFilter() { @Override public boolean accept(File file) { String name = file.getName(); return name.endsWith(FILE_EXTENSION) // it's a log file && name.contains(logDateFormatted) // it contains the date in the name && file.lastModified() >= dateMillis; // and it's not older than the search date } }); Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); if (files.length == 0) { Log.debug("No log files ending with {}, containing {}, modified after {}, at {}", FILE_EXTENSION, logDateFormatted, date, logFolderPath); } else { Log.debug("Found log files for {}: {}", date, files); } return files; }
From source file:br.com.ezequieljuliano.argos.util.SendMail.java
public SendMail attaching(Attachment annex) throws FileNotFoundException { File fileAnnex = new File(annex.getPath()); if (!fileAnnex.exists()) { throw new FileNotFoundException("File (" + fileAnnex.getPath() + ") does not exist!"); }//from ww w.ja v a 2s . c o m this.attachment.add(annex); return this; }
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step3HITCreator.java
public void initialize() throws IOException { InputStream stream = this.getClass().getClassLoader().getResourceAsStream(SOURCE_MUSTACHE_TEMPLATE); if (stream == null) { throw new FileNotFoundException("Resource not found: " + SOURCE_MUSTACHE_TEMPLATE); }// w w w . j av a 2s . c om // compile template MustacheFactory mf = new DefaultMustacheFactory(); Reader reader = new InputStreamReader(stream, "utf-8"); mustache = mf.compile(reader, "template"); // output path if (!outputPath.exists()) { outputPath.mkdirs(); } }
From source file:de.jcup.egradle.core.VersionedFolderToUserHomeCopySupport.java
@Override public boolean copyFrom(RootFolderProvider rootFolderProvider) throws IOException { File internalFolder = rootFolderProvider.getRootFolder(); if (internalFolder == null) { /* has to be already logged by root folder provider */ return false; }//w w w . j a va 2s .c om if (!internalFolder.exists()) { throw new FileNotFoundException( "Did not find internal folder to copy from:" + internalFolder.toString()); } copySupport.copyDirectories(internalFolder, targetFolder, true); return true; }