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:edu.ucsf.rbvi.CyAnimator.internal.io.LoadSessionListener.java

public void handleEvent(SessionLoadedEvent e) {
    // Reset CyAnimator
    FrameManager.reset();/*from   www  .j  ava  2s.c om*/

    // Get the session
    CySession session = e.getLoadedSession();
    /*
    System.out.println("Session: "+session);
    for (String s: session.getAppFileListMap().keySet()) {
       System.out.println(s+":");
       for (File f: session.getAppFileListMap().get(s)) {
    System.out.println("File: "+f);
       }
    }
    */
    if (!session.getAppFileListMap().containsKey("CyAnimator"))
        return;

    // System.out.println("We have animation information!");

    // Ask the user if they want to load the frames?
    //
    try {
        File frameListFile = session.getAppFileListMap().get("CyAnimator").get(0);
        FileReader reader = new FileReader(frameListFile);
        BufferedReader bReader = new BufferedReader(reader);
        JSONParser parser = new JSONParser();
        Object jsonObject = parser.parse(bReader);

        // For each root network, get the 
        if (jsonObject instanceof JSONArray) {
            for (Object obj : (JSONArray) jsonObject) {
                try {
                    FrameManager.restoreFramesFromSession(registrar, session, (JSONObject) obj);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
        bReader.close();
        reader.close();
    } catch (FileNotFoundException fnf) {
        System.out.println("File not found exception: " + fnf.getMessage());
    } catch (IOException ioe) {
        System.out.println("IO exception: " + ioe.getMessage());
    } catch (ParseException pe) {
        System.out.println("Unable to parse JSON file: " + pe.getMessage());
        pe.printStackTrace();
    }

}

From source file:com.cimmyt.csv.FileManagerCSVImpl.java

/**
 * Get Object file samples of format CSV
 * @param name of the file// ww w  . j a va 2 s  . c  om
 */
@Override
public FileSampleCSVBean getFileSampleCSV(Media media, int typeFile, boolean isValidateHeader) {
    FileSampleCSVBean fileSampleCSV = new FileSampleCSVBean();
    int numberColumn;
    CsvReader csvReader = null;
    logger.info("Into the methos class FileManagerCSVImpl.....");
    Reader reader = getReader(media);
    try {
        csvReader = new CsvReader(reader);
        //Read the first line of the file
        csvReader.readRecord();
        numberColumn = csvReader.getColumnCount();
        if (isValidateHeader)
            if (!validateTypeFile(numberColumn, typeFile))
                return null;
        //read header of file
        for (int sizeHeader = 0; sizeHeader < numberColumn; sizeHeader++) {
            fileSampleCSV.getListHeaders().add(new StringBuilder(csvReader.get(sizeHeader)));
        }
        // read the body of file to samples
        while (csvReader.readRecord()) {
            RowCSV row = new RowCSV();
            for (int sizeRow = 0; sizeRow < numberColumn; sizeRow++) {
                row.getListRow().add(new StringBuilder(csvReader.get(sizeRow)));
            }
            fileSampleCSV.getListRowCSV().add(row);
        }
        return fileSampleCSV;
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage());
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex.getMessage());
        return null;
    } finally {
        if (csvReader != null)
            csvReader.close();
        try {
            reader.close();
            reader = null;
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
        media = null;
    }
    //return null;
}

From source file:com.netflix.spinnaker.echo.artifacts.TemplateBasedArtifactExtractor.java

@Override
public List<Artifact> getArtifacts(String source, Map payload) {
    if (webhookProperties == null) {
        return new ArrayList<>();
    }/*  w  w w . ja v  a2  s .  c  om*/

    String templatePath = webhookProperties.getTemplatePathForSource(source);
    if (StringUtils.isEmpty(templatePath)) {
        return (List<Artifact>) payload.getOrDefault("artifacts", new ArrayList<>());
    } else {
        MessageArtifactTranslator translator;
        try {
            translator = new MessageArtifactTranslator(new FileInputStream(templatePath));
        } catch (FileNotFoundException e) {
            throw new RuntimeException("Failed to read template path " + templatePath + ": " + e.getMessage(),
                    e);
        }

        List<Artifact> result = new ArrayList<>();
        try {
            result = translator.parseArtifacts(objectMapper.writeValueAsString(payload));
            log.info("Webhook artifacts were processed: {}", result);
        } catch (Exception e) {
            log.error("Unable to translate artifacts: {}", payload, e);
        }

        return result;
    }
}

From source file:com.googlecode.t7mp.TomcatConfigFilesSetup.java

protected void copyConfigResource(String name) {
    log.debug("Copy default config file '" + name + "' to " + catalinaBaseDir.getAbsolutePath() + "/conf/"
            + name);//from w  w w .j av  a2 s.  c  om
    try {
        this.setupUtil.copy(getClass().getResourceAsStream("conf/" + name),
                new FileOutputStream(new File(catalinaBaseDir, "/conf/" + name)));
    } catch (FileNotFoundException e) {
        throw new TomcatSetupException(e.getMessage(), e);
    } catch (IOException e) {
        throw new TomcatSetupException(e.getMessage(), e);
    }
}

From source file:it.geosolutions.geobatch.destination.action.DestinationBaseAction.java

private FeatureConfiguration unwrapFeatureConfig(EventObject event) throws ActionException {
    if (event instanceof FileSystemEvent) {
        FileSystemEvent fse = (FileSystemEvent) event;
        File file = fse.getSource();
        try {/* w  w w  .  ja v a  2  s. c  om*/
            return FeatureConfiguration.fromXML(new FileInputStream(file));
        } catch (FileNotFoundException ex) {
            throw new ActionException(this, ex.getMessage(), ex);
        }
    } else {
        throw new ActionException(this, "EventObject not handled " + event);
    }
}

From source file:com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter.java

protected void convertInternal(File inputFile, DocumentFormat inputFormat, File outputFile,
        DocumentFormat outputFormat) {/*  w w w.ja va2 s . c o  m*/
    InputStream inputStream = null;
    OutputStream outputStream = null;
    try {
        inputStream = new FileInputStream(inputFile);
        outputStream = new FileOutputStream(outputFile);
        convert(inputStream, inputFormat, outputStream, outputFormat);
    } catch (FileNotFoundException fileNotFoundException) {
        throw new IllegalArgumentException(fileNotFoundException.getMessage());
    } finally {
        IOUtils.closeQuietly(inputStream);
        IOUtils.closeQuietly(outputStream);
    }
}

From source file:com.thalesgroup.sonar.plugins.tusar.metrics.NewMetrics.java

/**
 * Read the embedded CSV file (or defined by the property) line and add the new metrics which are defined in it.
 *//* ww w .  j a  v a 2s .  c om*/
private void addNewMetrics() {
    ClassLoader classLoader = getClass().getClassLoader();

    File configFile = NewMetrics.getCSVFilePath() == null ? null : new File(NewMetrics.getCSVFilePath());
    if (configFile != null && configFile.exists()) {
        List<String[]> csvData = null;
        try {
            csvData = Utils.parseIniFile(configFile);
        } catch (FileNotFoundException e) {
            throw new NullPointerException(e.getMessage());
        }

        for (String[] metricsData : csvData) {
            Utils.getLogger().info(metricsData[Constants.METRIC_NAME] + " " + metricsData[Constants.METRIC_TYPE]
                    + " " + metricsData[Constants.METRIC_DOMAIN]);
            NewMetrics.addNewMetric(new Builder(Utils.convertToKeyNorm(metricsData[Constants.METRIC_NAME]),
                    metricsData[Constants.METRIC_NAME],
                    Metric.ValueType.valueOf(metricsData[Constants.METRIC_TYPE].toUpperCase())).setDirection(0)
                            .setQualitative(false).setDomain(metricsData[Constants.METRIC_DOMAIN]).create()
                            .setFormula(new SumChildValuesFormula(false)));
        }
    } else {
        List<String[]> csvData = null;
        try {
            csvData = Utils.parseIniInputStream(classLoader.getResourceAsStream(Constants.DEFAULT_METRICS_CSV));
        } catch (FileNotFoundException e) {
            throw new NullPointerException(e.getMessage());
        }

        for (String[] metricsData : csvData) {
            Utils.getLogger().info(metricsData[Constants.METRIC_NAME] + " " + metricsData[Constants.METRIC_TYPE]
                    + " " + metricsData[Constants.METRIC_DOMAIN]);
            NewMetrics.addNewMetric(new Builder(Utils.convertToKeyNorm(metricsData[Constants.METRIC_NAME]),
                    metricsData[Constants.METRIC_NAME],
                    Metric.ValueType.valueOf(metricsData[Constants.METRIC_TYPE].toUpperCase())).setDirection(0)
                            .setQualitative(false).setDomain(metricsData[Constants.METRIC_DOMAIN]).create()
                            .setFormula(new SumChildValuesFormula(false)));
        }
    }

}

From source file:com.aurel.track.lucene.index.associatedFields.textExctractor.HTMLExtractor.java

/**
 * Gets the text from file content /*from   w w  w.ja  v  a 2  s.c  o  m*/
 * @param file
 * @param fileExtension
 * @return
 */
@Override
public String getText(File file, String fileExtension) {
    FileInputStream fis = null;
    Reader reader = null;
    try {
        try {
            fis = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            LOGGER.info("File " + file.getName() + " not found. " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return null;
        }
        reader = new BufferedReader(new InputStreamReader(fis));
        DefaultStyledDocument dsd = new DefaultStyledDocument();
        HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
        htmlEditorKit.read(reader, dsd, 0);
        return dsd.getText(0, dsd.getLength());
    } catch (Exception e) {
        LOGGER.debug("Extracting text from the .htm or .html  file " + file.getName() + " failed with "
                + e.getMessage());
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    } finally {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (Exception e) {
            LOGGER.debug("Closing the reader for file " + file.getName() + " failed with " + e.getMessage());
        }
        try {
            if (fis != null) {
                fis.close();
            }
        } catch (Exception e) {
            LOGGER.debug("Closing the FileInputStream for file " + file.getName() + " failed with "
                    + e.getMessage());
        }
    }
    return null;
}

From source file:com.petpet.c3po.gatherer.FileMetadataStream.java

public String getData() {
    String data = null;/*from   www  .  j  ava  2 s.c o m*/
    try {
        InputStream is = new BufferedInputStream(new FileInputStream(new File(this.fileName)), 8192);
        data = this.readStream(this.fileName, is);
    } catch (FileNotFoundException e) {
        LOG.warn("An error occurred while openning the stream to {}. Error: {}", fileName, e.getMessage());
    }

    return data;
}

From source file:com.petpet.c3po.gatherer.FileMetadataStream.java

public String getData(File file) {
    String data = null;//from  w ww . j  a v a 2s  .  c om
    try {
        InputStream is = new BufferedInputStream(new FileInputStream(file), 8192);
        data = this.readStream(this.fileName, is);
    } catch (FileNotFoundException e) {
        LOG.warn("An error occurred while openning the stream to {}. Error: {}", fileName, e.getMessage());
    }

    return data;
}