Example usage for java.io FileNotFoundException FileNotFoundException

List of usage examples for java.io FileNotFoundException FileNotFoundException

Introduction

In this page you can find the example usage for java.io FileNotFoundException FileNotFoundException.

Prototype

public FileNotFoundException(String s) 

Source Link

Document

Constructs a FileNotFoundException with the specified detail message.

Usage

From source file:com.codefollower.lealone.omid.TestUtils.java

public static void delete(File f) throws IOException {
    if (f.isDirectory()) {
        for (File c : f.listFiles())
            delete(c);/*from   w ww . j  a v a2 s  .c om*/
    }
    if (!f.delete())
        throw new FileNotFoundException("Failed to delete file: " + f);
}

From source file:com.clican.pluto.common.resource.ClassPathResource.java

public OutputStream getOutputStream() throws FileNotFoundException {
    throw new FileNotFoundException("Classpath resourceOutputStream");
}

From source file:com.mayalogy.mayu.io.LocalDataManager.java

public static InputStream openResourceAsInputStream(final String resourceName) throws IOException {

    final InputStream in = LocalDataManager.class.getResourceAsStream(resourceName);
    if (in == null) {
        throw new FileNotFoundException("File not found: " + resourceName);
    }//  w ww. jav  a  2  s .c om
    return in;

}

From source file:de.laeubisoft.tools.ant.validation.Tools.java

/**
 * Creates a {@link RequestEntity} that can be used for submitting a file
 * //w w w .j a v a2 s.  c  om
 * @param params
 *            the params to use
 * @param methodParams
 *            the {@link HttpMethodParams} of the requesting method
 * @return {@link RequestEntity} that can be used for submitting the given
 *         file via Multipart
 * @throws IOException
 *             if something is wrong with the file...
 */
public static RequestEntity createFileUpload(File file, String filePartName, String charset,
        List<NameValuePair> params, HttpMethodParams methodParams) throws IOException {
    if (file == null) {
        throw new FileNotFoundException("file not present!");
    }
    List<Part> parts = nvToParts(params);
    FilePart fp = new FilePart(filePartName, file);
    fp.setContentType(URLConnection.guessContentTypeFromName(file.getName()));
    if (charset != null) {
        fp.setCharSet(charset);
    }
    parts.add(fp);
    return new MultipartRequestEntity(parts.toArray(new Part[0]), methodParams);
}

From source file:com.dhenton9000.json.JacksonFromStringDemo.java

public File convertClassPathToFileRef(String path) throws FileNotFoundException {

    if (this.getClass().getResource(path) != null)

        return new File(FileUtils.toFile(getClass().getResource(path)).getAbsolutePath());
    else {/*from w  w  w  .ja v  a 2 s  . com*/
        String info = String.format("unable to find file at '%s'", path);
        throw new FileNotFoundException(info);
    }
}

From source file:fm.last.moji.impl.GetInputStreamCommand.java

@Override
public void executeWithTracker(Tracker tracker) throws IOException {
    List<URL> paths = tracker.getPaths(key, domain);
    if (paths.isEmpty()) {
        throw new FileNotFoundException("key=" + key + ", domain=" + domain);
    }/*from  w  w w .ja v a  2  s  .c o  m*/
    IOException lastException = null;
    for (URL path : paths) {
        try {
            log.debug("Opened: {}", path);
            HttpURLConnection urlConnection = httpFactory.newConnection(path);
            stream = new FileDownloadInputStream(urlConnection.getInputStream(), readLock);
            return;
        } catch (IOException e) {
            log.debug("Failed to open input -> {}", path);
            log.debug("Exception was: ", e);
            lastException = e;
            IOUtils.closeQuietly(stream);
        }
    }
    throw lastException;
}

From source file:de.codesourcery.jasm16.compiler.io.ClassPathResource.java

@Override
public InputStream createInputStream() throws IOException {
    final InputStream stream = getClass().getClassLoader().getResourceAsStream(classpathLocation);
    if (stream == null) {
        throw new FileNotFoundException("Unable to load classpath resource '" + classpathLocation + "'");
    }/*  w  ww.j a  va 2s  .  c o m*/
    return stream;
}

From source file:br.com.riselabs.cotonet.model.db.Database.java

public static Connection getConnection() {
    Thread currentThread = Thread.currentThread();
    ClassLoader classloader = currentThread.getContextClassLoader();
    InputStream input = classloader.getResourceAsStream("db.properties");
    Properties prop = new Properties();
    try {/*  w ww  .  j a  v  a  2 s  . c  o  m*/
        if (input != null) {
            prop.load(input);
            input.close();
        } else {
            Logger.logStackTrace(new FileNotFoundException("The file 'db.properties was not found."));
        }
    } catch (IOException e) {
        Logger.logStackTrace(e);
    }
    String db = prop.getProperty("database.name");
    String user = prop.getProperty("database.user");
    String pass = prop.getProperty("database.password");
    return getConnection(db, user, pass);
}

From source file:mustache.specs.SpecResourceLocator.java

@Override
public TemplateSource sourceAt(final String uri) throws IOException {
    notNull(uri, "The uri is required.");
    notEmpty(uri.toString(), "The uri is required.");
    String location = resolve(normalize(uri));
    String text = templates.get(uri.toString());
    if (text == null) {
        throw new FileNotFoundException(location);
    }//  w  w  w . ja v a2 s  .c om
    return new StringTemplateSource(location, text);
}

From source file:com.galenframework.storage.repository.LocalFileStorage.java

@Override
public byte[] readFile(String imagePath) {
    try {/*from   ww w .  ja  va2 s .  co m*/
        File file = new File(root.getPath() + File.separator + imagePath);
        if (file.exists()) {
            return FileUtils.readFileToByteArray(file);
        } else {
            throw new FileNotFoundException(file.getPath());
        }
    } catch (Exception ex) {
        throw new RuntimeException("Can't read file: " + imagePath, ex);
    }
}