Example usage for java.io FileNotFoundException toString

List of usage examples for java.io FileNotFoundException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:vod.samesun.util.VideoPlayConfig.java

public Properties getProperties() {

    // Java.properties
    Properties props = new Properties();
    try {/* w  w  w .ja  v a 2 s  . co  m*/
        props.load(VideoPlayConfig.class.getClassLoader().getResourceAsStream("VideoPlay.properties"));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        logger.error(e.toString());
    } catch (IOException e) {
        e.printStackTrace();
        logger.error(e.toString());
    }
    return props;
}

From source file:com.yahoo.storm.yarn.TestConfig.java

private void unzipFile(String filePath) {
    FileInputStream fis = null;//from w  w w. j av  a 2s  .c  om
    ZipInputStream zipIs = null;
    ZipEntry zEntry = null;
    try {
        fis = new FileInputStream(filePath);
        zipIs = new ZipInputStream(new BufferedInputStream(fis));
        while ((zEntry = zipIs.getNextEntry()) != null) {
            try {
                byte[] tmp = new byte[4 * 1024];
                FileOutputStream fos = null;
                String opFilePath = "lib/" + zEntry.getName();
                if (zEntry.isDirectory()) {
                    LOG.debug("Create a folder " + opFilePath);
                    if (zEntry.getName().indexOf(Path.SEPARATOR) == (zEntry.getName().length() - 1))
                        storm_home = opFilePath.substring(0, opFilePath.length() - 1);
                    new File(opFilePath).mkdir();
                } else {
                    LOG.debug("Extracting file to " + opFilePath);
                    fos = new FileOutputStream(opFilePath);
                    int size = 0;
                    while ((size = zipIs.read(tmp)) != -1) {
                        fos.write(tmp, 0, size);
                    }
                    fos.flush();
                    fos.close();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        zipIs.close();
    } catch (FileNotFoundException e) {
        LOG.warn(e.toString());
    } catch (IOException e) {
        LOG.warn(e.toString());
    }
    LOG.info("storm_home: " + storm_home);
}

From source file:com.streamsets.pipeline.lib.parser.DataParserFactory.java

public DataParser getParser(File file, String fileOffset) throws DataParserException {
    try {/*from   w ww  . j  av  a2s . co  m*/
        return getParser(file.getName(), new FileInputStream(file), fileOffset);
    } catch (FileNotFoundException e) {
        throw new DataParserException(Errors.DATA_PARSER_00, file.getAbsolutePath(), e.toString(), e);
    }
}

From source file:org.codehaus.cargo.sample.maven2.runMojo.RunMojoTest.java

/**
 * Wait for the <code>cargo:run</code> mojo to start.
 * @throws Exception If anything fails./* ww w . ja v a2s.  com*/
 */
private void waitForRunMojoStart() throws Exception {
    String outputString = null;
    long timeout = 90 * 1000 + System.currentTimeMillis();
    while (System.currentTimeMillis() < timeout) {
        try {
            outputString = FileUtils.readFileToString(output);
        } catch (FileNotFoundException e) {
            outputString = e.toString();
        }

        if (outputString.contains("Press Ctrl-C to stop the container...")) {
            return;
        } else if (outputString.contains("BUILD FAILURE")) {
            fail("There has been a BUILD FAILURE. Please check file " + output);
            return;
        }

        Thread.sleep(1000);
        System.gc();
    }

    fail("The file " + output + " did not have the Ctrl-C message after 90 seconds. " + "Current content: \n\n"
            + outputString);
}

From source file:org.codehaus.cargo.sample.maven2.remoteDeploy.RemoteDeployTest.java

/**
 * Wait for remote deployment to start./*  w ww.  jav a 2  s  .c  o m*/
 * @throws Exception If anything fails.
 */
private void waitForRemoteDeployStart() throws Exception {
    String outputString = null;
    long timeout = 90 * 1000 + System.currentTimeMillis();
    while (System.currentTimeMillis() < timeout) {
        try {
            outputString = FileUtils.readFileToString(output);
        } catch (FileNotFoundException e) {
            outputString = e.toString();
        }

        if (outputString.contains("BUILD SUCCESS")) {
            return;
        } else if (outputString.contains("BUILD FAILURE")) {
            fail("There has been a BUILD FAILURE. Please check file " + output);
            return;
        }

        Thread.sleep(1000);
        System.gc();
    }

    fail("The file " + output + " did not have the BUILD SUCCESS message after 90 seconds. "
            + "Current content: \n\n" + outputString);
}

From source file:can.yrt.oba.serialization.JacksonSerializer.java

public <T> T deserialize(Reader reader, Class<T> cls) {
    try {/*  w  w w  . jav  a 2  s . co  m*/
        T t = getJsonParser(reader).readValueAs(cls);
        if (t == null) {
            // TODO: test switching from Gson for errors
            t = createFromError(cls, ObaApi.OBA_INTERNAL_ERROR, "Json error");
        }
        return t;
    } catch (FileNotFoundException e) {
        return createFromError(cls, ObaApi.OBA_NOT_FOUND, e.toString());
    } catch (JsonProcessingException e) {
        return createFromError(cls, ObaApi.OBA_INTERNAL_ERROR, e.toString());
    } catch (IOException e) {
        return createFromError(cls, ObaApi.OBA_IO_EXCEPTION, e.toString());
    }
}

From source file:org.codehaus.cargo.sample.maven2.uberwar_test.UberwarTest.java

/**
 * Test generation of Uberwars (merged WARs).
 * @throws Exception If anything fails./* w  w  w. ja  va2 s. c om*/
 */
public void testUberwar() throws Exception {
    File target = new File(System.getProperty("target"));
    final File projectDirectory = new File(target, "classes").getAbsoluteFile();

    final File output = new File(target, "output.log");
    final PrintStream outputStream = new PrintStream(output);

    final String[] options = new String[] { "-o", "-X", "clean", "verify" };

    new Thread(new Runnable() {
        public void run() {
            MavenCli maven2 = new MavenCli();
            maven2.doMain(options, projectDirectory.getPath(), outputStream, outputStream);
        }
    }).start();

    String outputString = null;
    long timeout = 90 * 1000 + System.currentTimeMillis();
    while (System.currentTimeMillis() < timeout) {
        try {
            outputString = FileUtils.readFileToString(output);
        } catch (FileNotFoundException e) {
            outputString = e.toString();
        }

        if (outputString.contains("BUILD SUCCESS")) {
            return;
        } else if (outputString.contains("BUILD FAILURE")) {
            fail("There has been a BUILD FAILURE. Please check file " + output);
            return;
        }

        Thread.sleep(1000);
        System.gc();
    }

    fail("The file " + output + " did not have the BUILD SUCCESS message after 60 seconds. "
            + "Current content: \n\n" + outputString);

    String projectVersion = System.getProperty("project.version");
    assertNotNull("System property project.version not set", projectVersion);

    File uberwarExpandedDirectory = new File(target,
            "classes/target/cargo-sample-maven2-uberwar-test-artifact-" + projectVersion);
    assertNotNull("Not a directory: " + uberwarExpandedDirectory, uberwarExpandedDirectory.isDirectory());

    File webXmlFile = new File(uberwarExpandedDirectory, "WEB-INF/web.xml");
    assertNotNull("Not a file: " + webXmlFile, webXmlFile.isFile());

    FileInputStream webXmlStream = new FileInputStream(webXmlFile);
    try {
        WebXml webXml = WebXmlIo.parseWebXml(webXmlStream, getEntityResolver());

        // Check that the security constraints are in the uberwar
        List<Element> securityConstraints = webXml.getTags(WebXmlType.SECURITY_CONSTRAINT);
        assertEquals(1, securityConstraints.size());
        List<Element> authConstraints = securityConstraints.get(0).getChildren(WebXmlType.AUTH_CONSTRAINT);
        assertEquals(1, authConstraints.size());
        List<Element> roleNames = authConstraints.get(0).getChildren(WebXmlType.ROLE_NAME);
        assertEquals(1, roleNames.size());
        assertEquals("cargo", roleNames.get(0).getText());

        // Check that the datasource definitions are in the uberwar
        List<Element> resourceRefs = webXml.getTags(WebXmlType.RESOURCE_REF);
        assertEquals(1, resourceRefs.size());
        List<Element> resRefNames = resourceRefs.get(0).getChildren("res-ref-name");
        assertEquals(1, resRefNames.size());
        assertEquals("jdbc/CargoDS", resRefNames.get(0).getText());
    } finally {
        webXmlStream.close();
    }
}

From source file:org.fcrepo.exporter.Exporter.java

private void exportMembers(final File file) {
    try {//from w  w w  .  ja  v a2s  . c  o  m
        final Model model = createDefaultModel().read(new FileInputStream(file), null, config.getRdfLanguage());
        for (final NodeIterator it = model.listObjectsOfProperty(CONTAINS); it.hasNext();) {
            export(new URI(it.nextNode().toString()));
        }
    } catch (FileNotFoundException ex) {
        logger.warn("Unable to parse file: {}", ex.toString());
    } catch (URISyntaxException ex) {
        logger.warn("Unable to parse URI: {}", ex.toString());
    }
}

From source file:BwaSingleAlignment.java

/**
 * Code to run in each one of the mappers. This is, the alignment with the corresponding entry data
 * The entry data has to be written into the local filesystem
 *///w  w  w .j  ava2 s .c  o m
@Override
public Iterator<String> call(Integer arg0, Iterator<String> arg1) throws Exception {

    LOG.info("JMAbuin:: Tmp dir: " + this.tmpDir);
    String fastqFileName1 = this.tmpDir + this.appId + "-RDD" + arg0 + "_1";

    LOG.info("JMAbuin:: Writing file: " + fastqFileName1);

    File FastqFile1 = new File(fastqFileName1);
    FileOutputStream fos1;
    BufferedWriter bw1;

    ArrayList<String> returnedValues = new ArrayList<String>();

    try {
        fos1 = new FileOutputStream(FastqFile1);
        bw1 = new BufferedWriter(new OutputStreamWriter(fos1));

        String newFastqRead;

        while (arg1.hasNext()) {
            newFastqRead = arg1.next();

            bw1.write(newFastqRead.toString());
            bw1.newLine();
        }

        bw1.close();

        //We do not need the input data anymore, as it is written in a local file
        arg1 = null;

        returnedValues = this.runAlignmentProcess(arg0, fastqFileName1, null);
        // Delete the temporary file, as is have now been copied to the
        // output directory
        FastqFile1.delete();

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        LOG.error(e.toString());
    }

    return returnedValues.iterator();
}

From source file:org.activiti.osgi.blueprint.BlueprintBasicTest.java

protected InputStream createTestBundleWithTask() {
    try {//from w  ww  . j a va  2s .  co  m
        return TinyBundles.bundle()
                .add("OSGI-INF/blueprint/context.xml",
                        new FileInputStream(new File("src/test/resources/task/context.xml")))
                .add(SimpleBean.class).set(Constants.BUNDLE_SYMBOLICNAME, "org.activiti.osgi.task")
                .set(Constants.DYNAMICIMPORT_PACKAGE, "*").build();
    } catch (FileNotFoundException fnfe) {
        fail("Failure in createTestBundleWithTask " + fnfe.toString());
        return null;
    }
}