Example usage for java.io FileNotFoundException getMessage

List of usage examples for java.io FileNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.l2jfree.gameserver.model.L2Manor.java

private void parseData() {
    LineNumberReader lnr = null;/* w ww.j  av  a  2 s.  c  o  m*/
    try {
        File seedData = new File(Config.DATAPACK_ROOT, "data/seeds.csv");
        lnr = new LineNumberReader(new BufferedReader(new FileReader(seedData)));

        String line = null;
        while ((line = lnr.readLine()) != null) {
            if (line.trim().length() == 0 || line.startsWith("#"))
                continue;
            SeedData seed = parseList(line);
            _seeds.put(seed.getId(), seed);
        }

        _log.info("ManorManager: Loaded " + _seeds.size() + " seeds");
    } catch (FileNotFoundException e) {
        _log.info("seeds.csv is missing in data folder", e);
    } catch (Exception e) {
        _log.info("error while loading seeds: " + e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(lnr);
    }
}

From source file:de.kaiserpfalzEdv.maven.apacheds.config.LdifLoader.java

private void loadLdifFile(final File ldif) throws MojoExecutionException {
    logger.debug("Loading LDIF: " + ldif);

    try {//w w  w  . jav a2 s . c o  m
        LdifReader ldifReader = new LdifReader();

        for (LdifEntry entry : ldifReader.parseLdif(new BufferedReader(new FileReader(ldif)))) {
            addLdifEntry(entry);
        }
    } catch (FileNotFoundException e) {
        logger.error("File '" + ldif + "' not found. LDIF will not be loaded!");

        throw new MojoExecutionException("Can't load configured LDIF '" + ldif + "'. Tests will fail!", e);
    } catch (Exception e) {
        logger.error(e.getClass().getSimpleName() + " caught: " + e.getMessage(), e);
    }
}

From source file:com.android.sdklib.repository.legacy.remote.internal.DownloadCacheTest.java

public void testMissingResource() throws Exception {
    // Downloads must fail when using the only-cache strategy and there's nothing in the cache.
    // In that case, it returns null to indicate the resource is simply not found.
    // Since the mock implementation always returns a 404 and no stream, there is no
    // difference between the various cache strategies.

    mFileOp.reset();//  www  . j  a va2 s.co m
    NoDownloadCache d1 = new NoDownloadCache(mFileOp, DownloadCache.Strategy.ONLY_CACHE);
    InputStream is1 = d1.openCachedUrl("http://www.example.com/download1.xml", mMonitor);
    assertNull(is1);
    assertEquals("", mMonitor.getAllCapturedLogs());
    assertTrue(mFileOp.hasRecordedExistingFolder(d1.getCacheRoot()));
    assertEquals("", mFileOp.getWrittenFiles());

    // HTTP-Client's behavior is to return a FNF instead of 404 so we'll try that first
    mFileOp.reset();
    NoDownloadCache d2 = new NoDownloadCache(mFileOp, DownloadCache.Strategy.DIRECT);

    try {
        d2.openCachedUrl("http://www.example.com/download1.xml", mMonitor);
        fail("Expected: NoDownloadCache.openCachedUrl should have thrown a FileNotFoundException");
    } catch (FileNotFoundException e) {
        assertEquals("http://www.example.com/download1.xml", e.getMessage());
    }
    assertEquals("", mMonitor.getAllCapturedLogs());
    assertEquals("", mFileOp.getWrittenFiles());

    // Try again but this time we'll define a 404 reply to test the rest of the code path.
    mFileOp.reset();
    d2.registerResponse("http://www.example.com/download1.xml", 404, null);
    InputStream is2 = d2.openCachedUrl("http://www.example.com/download1.xml", mMonitor);
    assertNull(is2);
    assertEquals("", mMonitor.getAllCapturedLogs());
    assertEquals("", mFileOp.getWrittenFiles());

    mFileOp.reset();
    NoDownloadCache d3 = new NoDownloadCache(mFileOp, DownloadCache.Strategy.SERVE_CACHE);
    d3.registerResponse("http://www.example.com/download1.xml", 404, null);
    InputStream is3 = d3.openCachedUrl("http://www.example.com/download1.xml", mMonitor);
    assertNull(is3);
    assertEquals("", mMonitor.getAllCapturedLogs());
    assertEquals("", mFileOp.getWrittenFiles());

    mFileOp.reset();
    NoDownloadCache d4 = new NoDownloadCache(mFileOp, DownloadCache.Strategy.FRESH_CACHE);
    d4.registerResponse("http://www.example.com/download1.xml", 404, null);
    InputStream is4 = d4.openCachedUrl("http://www.example.com/download1.xml", mMonitor);
    assertNull(is4);
    assertEquals("", mMonitor.getAllCapturedLogs());
    assertEquals("", mFileOp.getWrittenFiles());
}

From source file:com.mnxfst.testing.AbstractTSCommandLineTool.java

/**
 * Reads additional properties from the referenced file
 * @param additionalPropertiesFile//from   w  ww . ja va2  s  .c o  m
 * @return
 * @throws TSClientConfigurationException
 */
public Properties extractAdditionalProperties(String additionalPropertiesFile)
        throws TSClientConfigurationException {

    if (additionalPropertiesFile == null || additionalPropertiesFile.isEmpty()
            || additionalPropertiesFile.trim().isEmpty())
        throw new TSClientConfigurationException("No file name provided");

    try {
        FileInputStream fIn = new FileInputStream(additionalPropertiesFile);
        Properties props = new Properties();
        props.load(fIn);
        return props;
    } catch (FileNotFoundException e) {
        throw new TSClientConfigurationException("No such file '" + additionalPropertiesFile + "'");
    } catch (IOException e) {
        throw new TSClientConfigurationException(
                "Error while reading from '" + additionalPropertiesFile + "': " + e.getMessage());
    }

}

From source file:gestionale.persistence.DAOSalva.java

public void scriviFileSalva(int numeroAvii) {
    numeroAvii--;/*from www .  j a v  a 2  s . com*/
    if (numeroAvii >= 0) {
        try {
            PrintStream ps = new PrintStream(new FileOutputStream("License.txt"));
            String caratteriCifrati = encrypt("" + numeroAvii);
            //logger.info(caratteriCifrati);
            ps.println(caratteriCifrati);
            ps.close();
        } catch (FileNotFoundException ex) {
            logger.info("FileNotFoundException: " + ex.getMessage());
        }
    }
}

From source file:com.sun.portal.rssportlet.RssPortlet.java

private void processEditAddAction(ActionRequest request, ActionResponse response, AlertHandler alertHandler,
        Resources resources, SettingsBean readBean, SettingsBean writeBean) {
    String url = request.getParameter(INPUT_ADD_FEED);
    try {/*from  www.j ava  2s  .  com*/
        // see if the url exists
        // if there's no exception, then the feed exists and is valid
        FeedHelper.getInstance().getFeed(readBean, url);

        //add to the existing values
        LinkedList feeds = readBean.getFeeds();
        feeds.add(url);
        writeBean.setFeeds(feeds);

        //
        // set newly added feed as selected feed
        //
        writeBean.setSelectedFeed(url);

        // we stay in edit mode here
    } catch (MalformedURLException mue) {
        alertHandler.setError(resources.get("invalid_url"), mue.getMessage());
        log.info("MalformedURLException: " + mue.getMessage());
        getPortletConfig().getPortletContext().log("could not add feed", mue);
    } catch (UnknownHostException uhe) {
        alertHandler.setError(resources.get("invalid_url"), uhe.getMessage());
        log.info("UnknownHostException: " + uhe.getMessage());
    } catch (FileNotFoundException fnfe) {
        alertHandler.setError(resources.get("invalid_url"), fnfe.getMessage());
        log.info("FileNotFoundException: " + fnfe.getMessage());
        getPortletConfig().getPortletContext().log("could not add feed", fnfe);
    } catch (IllegalArgumentException iae) {
        alertHandler.setError(resources.get("invalid_url"), iae.getMessage());
        log.info("IllegalArgumentException: " + iae.getMessage());
        getPortletConfig().getPortletContext().log("could not add feed", iae);
    } catch (FeedException fe) {
        alertHandler.setError(resources.get("invalid_url"), fe.getMessage());
        log.info("FeedException: " + fe.getMessage());
        getPortletConfig().getPortletContext().log("could not add feed", fe);
    } catch (IOException ioe) {
        alertHandler.setError(resources.get("invalid_url"), ioe.getMessage());
        log.info("IOException: " + ioe.getMessage());
        getPortletConfig().getPortletContext().log("could not add feed", ioe);
    } catch (Exception ex) {
        alertHandler.setError(resources.get("invalid_url"), ex.getMessage());
        log.info("Exception: " + ex.getMessage());
        getPortletConfig().getPortletContext().log("could not add feed", ex);
    }
}

From source file:org.androdyne.StacktraceUploader.java

/**
 * Read a trace file and return its values as a list of NameValuePairs
 **//*from   w ww  .j a  v  a 2 s. co m*/
private List<NameValuePair> readStacktrace(File file) {
    try {
        List<NameValuePair> retval = new LinkedList<NameValuePair>();

        BufferedReader input = new BufferedReader(new FileReader(file), Constants.BUFSIZE);
        String line = null;
        while (null != (line = input.readLine())) {
            int sepPos = line.indexOf(Constants.PARAM_SEP);
            if (-1 == sepPos) {
                android.util.Log.e(LTAG, "Could not parse trace line: " + line);
                continue;
            }
            String key = line.substring(0, sepPos);
            String value = line.substring(sepPos + 1);
            retval.add(new BasicNameValuePair(key, value));
        }
        input.close();

        return retval;
    } catch (FileNotFoundException ex) {
        // Ignore. This happens if the file has already been processed by another
        // handler in the same process.
    } catch (IOException ex) {
        android.util.Log.e(LTAG, "IO Exception: " + ex.getMessage());
    }
    return null;
}

From source file:XMLReader.java

/** Parses XML file and returns XML document.
 * @param fileName XML file to parse//  w w  w . j ava 2 s .  c o  m
 * @return XML document or <B>null</B> if error occured
 */
private Document parseFile(String fileName) {
    System.out.println("Parsing XML file... " + fileName);
    DocumentBuilder docBuilder;
    Document doc = null;
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringElementContentWhitespace(true);

    boolean success = true;

    try {
        docBuilder = docBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        System.err.println("XMLReader::parseFile - Wrong parser configuration: " + e.getMessage());
        success = false;
        return null;
    }
    File sourceFile = new File(fileName);
    try {
        doc = docBuilder.parse(sourceFile);
    } catch (SAXException e) {
        System.err.println("XMLReader::parseFile - Wrong XML file structure: " + e.getMessage());
        success = false;
        return null;
    } catch (FileNotFoundException catcher) {
        System.err.println("AgencyTable::initNames - AgencyInfo.skc not Found: " + catcher.getMessage());
        System.out.println("Expected XML file to be in following location: " + System.getProperty("user.dir")
                + "\\" + fileName + ".");
    } catch (IOException e) {
        System.err.println("XMLReader::parseFile - Could not read source file: " + e.getMessage());
        success = false;
    }
    System.out.println("XML file parsed" + (success ? "" : " - but with errors"));

    if (!success) {
        System.out.println("Error reading XML file.  Refer to the log file for more information.");
    }

    return doc;
}

From source file:de.iteratec.iteraplan.businesslogic.service.SvgExportServiceImplTest.java

/**
 * @param doc Document containing the export
 * @param exp String being looked for//  w w  w  .  j  ava2  s  .  co  m
 * 
 * @return whether the string is contained 
 */
private boolean svgFileContains(String exp) {

    // initiating the BufferedReader
    BufferedReader br = null;
    try {
        br = new BufferedReader(new FileReader(outputFile));
    } catch (FileNotFoundException e) {
        LOGGER.error(e.getMessage(), e);
    }

    // reading the file
    try {
        String line;
        line = br.readLine();
        while (line != null) {
            if (line.contains(exp)) {
                return true;
            }
            line = br.readLine();
        }
    } catch (IOException e) {
        LOGGER.error(e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(br);
    }

    return false;
}

From source file:com.microsoft.applicationinsights.internal.channel.common.TransmissionFileSystemOutput.java

private Optional<Transmission> loadTransmission(File file) {
    Transmission transmission = null;//w w  w.j  av a  2  s  .  c om

    InputStream fileInput = null;
    ObjectInput input = null;
    try {
        if (file == null) {
            return Optional.absent();
        }

        fileInput = new FileInputStream(file);
        InputStream buffer = new BufferedInputStream(fileInput);
        input = new ObjectInputStream(buffer);
        transmission = (Transmission) input.readObject();
    } catch (FileNotFoundException e) {
        InternalLogger.INSTANCE.error("Failed to load transmission, file not found, exception: %s",
                e.getMessage());
    } catch (ClassNotFoundException e) {
        InternalLogger.INSTANCE.error("Failed to load transmission, non transmission, exception: %s",
                e.getMessage());
    } catch (IOException e) {
        InternalLogger.INSTANCE.error("Failed to load transmission, io exception: %s", e.getMessage());
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
            }
        }
    }

    return Optional.fromNullable(transmission);
}