List of usage examples for java.io FileNotFoundException FileNotFoundException
public FileNotFoundException(String s)
FileNotFoundException
with the specified detail message. From source file:com.igormaznitsa.nbmindmap.utils.FakeFileObject.java
@Override public InputStream getInputStream() throws FileNotFoundException { throw new FileNotFoundException("It's a fake file object"); }
From source file:control.services.DownloadPortraitsHttpServiceImpl.java
@Override public int getSize(String portraitsFileName) throws FileNotFoundException { int size = 0; URL website;//from w w w . j av a2 s . c om URLConnection conn = null; try { website = new URL(PROTOCOL_HOST + CLASH_HOST + PORTRAITS_PATH + portraitsFileName); // website = new URL("https://www.colorado.edu/conflict/peace/download/peace.zip"); conn = website.openConnection(); if (conn instanceof HttpURLConnection) { ((HttpURLConnection) conn).setRequestMethod("HEAD"); } conn.getInputStream(); size = conn.getContentLength(); } catch (IOException ex) { LOG.error(ex); throw new FileNotFoundException(ex.getMessage()); } finally { if (conn instanceof HttpURLConnection) { ((HttpURLConnection) conn).disconnect(); } } return size; }
From source file:com.bah.lucene.hdfs.HdfsDirectory.java
@Override public IndexInput openInput(String name, IOContext context) throws IOException { LOG.debug(MessageFormat.format("openInput [{0}] [{1}] [{2}]", name, context, _path)); if (!fileExists(name)) { throw new FileNotFoundException("File [" + name + "] not found."); }//from w w w . j a va 2s . c om FSDataInputStream inputStream = openForInput(name); long fileLength = fileLength(name); return new HdfsIndexInput(name, inputStream, fileLength, fetchImpl.get()); }
From source file:com.oakesville.mythling.util.Recorder.java
/** * Wait for recording to be available.//from w w w . j ava 2s . c o m */ public void waitAvailable() throws IOException, JSONException, ParseException, InterruptedException { // wait for content to be available int timeout = appSettings.getTunerTimeout() * 1000; while (recording == null && timeout > 0) { if (BuildConfig.DEBUG) Log.d(TAG, "Awaiting recording ..."); long before = System.currentTimeMillis(); recording = getRecording(tvShow); long elapsed = System.currentTimeMillis() - before; if (elapsed < 1000) { Thread.sleep(1000 - elapsed); timeout -= 1000; } else { timeout -= elapsed; } } if (recording == null) { if (recRuleId > 0) { // remove the recording rule URL remRecUrl = new URL( appSettings.getMythTvServicesBaseUrl() + "/Dvr/RemoveRecordSchedule?RecordId=" + recRuleId); getServiceHelper(remRecUrl).post(); } throw new FileNotFoundException(Localizer.getStringRes(R.string.no_recording_available)); } // wait a few seconds int lagSeconds = 10; // TODO: prefs Thread.sleep(lagSeconds * 1000); }
From source file:com.googlecode.osde.internal.profiling.Profile.java
/** * Installs a Firefox extension into this user profile. * * @param classpath The classpath of extension XPI file. * @param id The extension id./* w ww.j a va 2 s . com*/ */ private void addExtension(String classpath, String id) throws IOException { // Firefox looks up extensions in // <profiledir>/<extensions>/<extension-id>. File extensionDirectory = new File(extensionsDir, id); if (extensionDirectory.exists() && extensionDirectory.isDirectory()) { // we assume the extension is already installed and will not do it // again. return; } InputStream resource = Profile.class.getResourceAsStream(classpath); if (resource == null && !classpath.startsWith("/")) { resource = Profile.class.getResourceAsStream("/" + classpath); } if (resource == null) { throw new FileNotFoundException("Cannot locate resource with name: " + classpath); } forceMkdir(extensionDirectory); unzip(resource, extensionDirectory); }
From source file:com.skynetcomputing.skynetserver.persistence.FileManager.java
protected File getJobFolder(int jobID) throws FileNotFoundException { File file = new File(JOB_FOLDER_PATH + File.separator + jobID); if (!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath()); }/*from w w w . ja v a 2 s . c o m*/ return file; }
From source file:org.eclipse.hono.service.auth.impl.FileBasedAuthenticationService.java
/** * Loads permissions from <em>permissionsPath</em>. * // w w w .j a v a2s . c o m * @throws IOException if the permissions cannot be read. * @throws IllegalStateException if no permissions resource path is set. */ void loadPermissions() throws IOException { if (getConfig().getPermissionsPath() == null) { throw new IllegalStateException("permissions resource is not set"); } if (getConfig().getPermissionsPath().isReadable()) { log.info("loading permissions from resource {}", getConfig().getPermissionsPath().getURI().toString()); final StringBuilder json = new StringBuilder(); load(getConfig().getPermissionsPath(), json); parsePermissions(new JsonObject(json.toString())); } else { throw new FileNotFoundException("permissions resource does not exist"); } }
From source file:android.database.DatabaseUtils.java
public static void readExceptionWithFileNotFoundExceptionFromParcel(Parcel reply) throws FileNotFoundException { int code = reply.readInt(); if (code == 0) return;/*from w w w . ja v a 2 s . com*/ String msg = reply.readString(); if (code == 1) { throw new FileNotFoundException(msg); } else { DatabaseUtils.readExceptionFromParcel(reply, msg, code); } }
From source file:JarUtils.java
/** * <P>This function will create a Jar archive containing the src * file/directory. The archive will be written to the specified * OutputStream. Directories are processed recursively, applying the * specified filter if it exists./*from w w w .j a v a 2 s. co m*/ * * @param out The output stream to which the generated Jar archive is * written. * @param src The file or directory to jar up. Directories will be * processed recursively. * @param filter The filter to use while processing directories. Only * those files matching will be included in the jar archive. If * null, then all files are included. * @param prefix The name of an arbitrary directory that will precede all * entries in the jar archive. If null, then no prefix will be * used. * @param man The manifest to use for the Jar archive. If null, then no * manifest will be included. * @throws IOException */ public static void jar(OutputStream out, File[] src, FileFilter filter, String prefix, Manifest man) throws IOException { for (int i = 0; i < src.length; i++) { if (!src[i].exists()) { throw new FileNotFoundException(src.toString()); } } JarOutputStream jout; if (man == null) { jout = new JarOutputStream(out); } else { jout = new JarOutputStream(out, man); } if (prefix != null && prefix.length() > 0 && !prefix.equals("/")) { // strip leading '/' if (prefix.charAt(0) == '/') { prefix = prefix.substring(1); } // ensure trailing '/' if (prefix.charAt(prefix.length() - 1) != '/') { prefix = prefix + "/"; } } else { prefix = ""; } JarInfo info = new JarInfo(jout, filter); for (int i = 0; i < src.length; i++) { jar(src[i], prefix, info); } jout.close(); }
From source file:ja.centre.util.io.Files.java
public static File create(String fileName) throws FileNotFoundException { Arguments.assertNotNull("fileName", fileName); File file = new File(fileName); if (!file.exists()) { throw new FileNotFoundException(fileName); }/* w ww .ja va 2s . c om*/ return file; }