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:fm.last.moji.local.LocalMojiFile.java

@Override
public void copyToFile(File destination) throws IOException {
    if (!file.exists()) {
        throw new FileNotFoundException(file.getCanonicalPath());
    }/*w  w  w  .j a  va2 s . c om*/
    FileUtils.copyFile(file, destination);
}

From source file:com.qwazr.webapps.transaction.ControllerManager.java

void handle(WebappTransaction transaction, String controllerPath)
        throws URISyntaxException, IOException, InterruptedException, ReflectiveOperationException,
        ServletException, ScriptException, PrivilegedActionException {
    if (controllerPath == null)
        return;/*from ww w  . java  2  s .  c o m*/
    File controllerFile = new File(dataDir, controllerPath);
    if (controllerFile.exists()) {
        if (!controllerFile.isFile())
            throw new FileNotFoundException("Controller not found: " + controllerPath);
        handleFile(transaction, controllerFile);
    } else
        handleJavaClass(transaction, controllerPath);
}

From source file:de.jcup.egradle.codeassist.dsl.FilesystemFileLoader.java

@Override
public Type loadType(String name) throws IOException {
    if (dslFolder == null) {
        throw new DSLFolderNotSetException();
    }// ww  w  .  j  a  v  a2  s . c  om
    if (StringUtils.isBlank(name)) {
        return null;
    }
    if (!dslFolder.exists()) {
        throw new DSLFolderNotValidException("DSL folder does not exist:" + dslFolder);
    }
    if (!dslFolder.isDirectory()) {
        throw new DSLFolderNotValidException("DSL folder ist not a directory:" + dslFolder);
    }
    String path = PATTERN_EVERY_DOT.matcher(name).replaceAll("/");
    path += ".xml";
    File sourceFile = new File(dslFolder, path);
    if (!sourceFile.exists()) {
        throw new FileNotFoundException("Did not found:" + sourceFile);
    }
    InputStream stream = new FileInputStream(sourceFile);

    Type type = typeImporter.importType(stream);

    return type;
}

From source file:io.github.retz.executor.FileManager.java

private static void fetchHTTPFile(String file, String dest) throws IOException {
    URL url = new URL(file);

    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("GET");

    conn.setDoOutput(true);//from w  w  w. j  ava  2  s . c  o m
    java.nio.file.Path path = Paths.get(file).getFileName();
    if (path == null) {
        throw new FileNotFoundException(file);
    }
    String filename = path.toString();
    InputStream input = null;
    try (FileOutputStream output = new FileOutputStream(dest + "/" + filename)) {
        input = conn.getInputStream();
        byte[] buffer = new byte[65536];
        int bytesRead = 0;
        while ((bytesRead = input.read(buffer)) != -1) {
            output.write(buffer, 0, bytesRead);
        }
    } catch (IOException e) {
        LOG.debug(e.getMessage());
        throw e;
    } finally {
        if (input != null)
            input.close();
    }
    conn.disconnect();
    LOG.info("Download finished: {}", file);
}

From source file:com.cedarsoft.serialization.serializers.jackson.registry.FileBasedObjectsAccess.java

@Nonnull
@Override//  w w w.jav a 2 s  .c  o m
public Set<? extends String> getIds() throws IOException {
    assert baseDir.exists();
    File[] files = baseDir.listFiles((FileFilter) new SuffixFileFilter(extension));
    if (files == null) {
        throw new FileNotFoundException("Could not list files in " + baseDir.getAbsolutePath());
    }

    Set<String> ids = new HashSet<String>();
    for (File file : files) {
        ids.add(FilenameUtils.getBaseName(file.getName()));
    }

    return ids;
}

From source file:com.openkm.util.impexp.RepositoryExporter.java

/**
 * Performs a recursive repository content export with metadata
 *///from w w  w . j  a  va 2 s . c o  m
public static ImpExpStats exportDocuments(String token, String fldPath, File fs, boolean metadata,
        boolean history, Writer out, InfoDecorator deco)
        throws PathNotFoundException, AccessDeniedException, RepositoryException, IOException,
        DatabaseException, ParseException, NoSuchGroupException, MessagingException {
    log.debug("exportDocuments({}, {}, {}, {}, {}, {}, {})",
            new Object[] { token, fldPath, fs, metadata, history, out, deco });
    ImpExpStats stats;

    try {
        FileLogger.info(BASE_NAME, "Start repository export from ''{0}'' to ''{1}''", fldPath, fs.getPath());

        if (fs.exists()) {
            firstTime = true;
            stats = exportDocumentsHelper(token, fldPath, fs, metadata, history, out, deco);
        } else {
            throw new FileNotFoundException(fs.getPath());
        }

        FileLogger.info(BASE_NAME, "Repository export finalized");
    } catch (PathNotFoundException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "PathNotFoundException ''{0}''", e.getMessage());
        throw e;
    } catch (AccessDeniedException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "AccessDeniedException ''{0}''", e.getMessage());
        throw e;
    } catch (FileNotFoundException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "FileNotFoundException ''{0}''", e.getMessage());
        throw e;
    } catch (RepositoryException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "RepositoryException ''{0}''", e.getMessage());
        throw e;
    } catch (IOException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "IOException ''{0}''", e.getMessage());
        throw e;
    } catch (DatabaseException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "DatabaseException ''{0}''", e.getMessage());
        throw e;
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "ParseException ''{0}''", e.getMessage());
        throw e;
    } catch (NoSuchGroupException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "NoSuchGroupException ''{0}''", e.getMessage());
        throw e;
    } catch (MessagingException e) {
        log.error(e.getMessage(), e);
        FileLogger.error(BASE_NAME, "MessagingException ''{0}''", e.getMessage());
        throw e;
    }

    log.debug("exportDocuments: {}", stats);
    return stats;
}

From source file:msuresh.raftdistdb.AtomixDB.java

public static void delete(File path) throws FileNotFoundException {
    if (!path.exists())
        throw new FileNotFoundException(path.getAbsolutePath());
    for (File f : path.listFiles()) {
        f.delete();/*from  w  ww .  ja  v a  2  s . c  o m*/
    }

}

From source file:blueprint.sdk.util.map.KeyValueStore.java

/**
 * Load JSON file and populate key/value map
 *
 * @throws IOException          Can't read JSON file
 * @throws JsonMappingException Invalid JSON mapping
 * @throws JsonParseException   Invalid JSON file
 *//* www . j a v  a  2s . co  m*/
public void load() throws IOException {
    if (jsonFile == null) {
        throw new NullPointerException("JSON file is not specified");
    }

    if (jsonFile.exists()) {
        TypeReference<HashMap<String, T>> typeRef = new TypeReference<HashMap<String, T>>() {
        };
        HashMap<String, T> map = mapper.readValue(jsonFile, typeRef);

        synchronized (lock) {
            kvMap.clear();
            kvMap.putAll(map);
        }
    } else {
        throw new FileNotFoundException("JSON file is not exist");
    }
}

From source file:it.larusba.integration.couchbase.document.transformer.RemoteNeo4jTransformer.java

/**
 * It perform the REST call to the URL configured in the
 * transofrmer.properties file//from  w  w w.  j  a va  2s  .c o  m
 * 
 * @throws IOException
 */
private void transformJson2Cypher(String documentKey, String documentType, String jsonDocument)
        throws IOException {

    Properties prop = new Properties();
    String propFileName = "transformer.properties";

    inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);

    if (inputStream != null) {
        prop.load(inputStream);
    } else {
        throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
    }

    // get the URL property value
    String urlJson2Cypher = prop.getProperty("transformer.url");

    JsonDocument documentToTransform = new JsonDocument(documentKey, jsonDocument, documentType);

    HttpClient httpClient = HttpClientBuilder.create().build();

    HttpPut putRequest = new HttpPut(urlJson2Cypher);
    putRequest.addHeader("content-type", MediaType.APPLICATION_JSON);

    JSONObject json = new JSONObject(documentToTransform);

    StringEntity entity = new StringEntity(json.toString());

    putRequest.setEntity(entity);

    HttpResponse response = httpClient.execute(putRequest);

    if (response.getStatusLine().getStatusCode() != 200) {

        throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
    }
}

From source file:com.xtesy.core.internals.impl.Settings.java

/**
 * @author Wasiq B//from w  ww  . j  a  va  2 s  .c om
 * @throws ConfigurationException
 * @throws FileNotFoundException
 * @since 04-Jul-2015 6:17:05 pm
 */
private void parseConfig() throws ConfigurationException, FileNotFoundException {
    String file = getString(Constants.TEST_CONFIG_FILE);
    if (file == null) {
        file = "test.properties";
    }
    final URL url = FileUtils.getResource(file);
    if (url == null)
        throw new FileNotFoundException(file);
    this.prop = new PropertiesConfiguration(url);
    this.prop.setAutoSave(true);
    this.prop.setReloadingStrategy(new FileChangedReloadingStrategy());
    addConfiguration(this.prop);
}