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:au.edu.unsw.cse.soc.federatedcloud.community.driven.cloudbase.connectors.docker.DockerConnector.java

private File writeStringToFile(String fileName, String fileContent) {
    File file = new File(fileName);
    boolean dirCreated = file.getParentFile().mkdirs();
    PrintWriter out = null;/*from ww  w .j  a va2 s.c  o  m*/
    try {
        out = new PrintWriter(file);
    } catch (FileNotFoundException e) {
        log.error(e.getMessage(), e);
    }
    out.println(fileContent);
    out.flush();
    out.close();
    return file;
}

From source file:edu.clemson.lph.civet.addons.VspsCviFile.java

private void saveme(Window parent, File fIn) {
    try {//from   w ww .  j a v a 2 s  . c  o m
        File fOut = fixCSV(fIn);
        CSVParser parserIn = new CSVParser(new FileReader(fOut), CSVFormat.EXCEL);
        parser = new LabeledCSVParser(parserIn);
        aCols = parser.getNext();
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage() + "\nCould not read file: " + fIn.getName());
    } catch (IOException e) {
        logger.error(e.getMessage() + "\nCould not read file: " + fIn.getName());
    }
    InsertVspsCviThread thread = new InsertVspsCviThread(parent, this);
    thread.start();
}

From source file:info.magnolia.filesystembrowser.app.subapp.imageeditor.ImageEditorSubApp.java

@Override
public ImageEditorSubAppView start(Location location) {
    super.start(location);
    DetailLocation detailLocation = DetailLocation.wrap(location);

    this.file = (File) contentConnector.getItemIdByUrlFragment(detailLocation.getNodePath());
    this.mediaEditorPresenter = mediaEditorFactory.getPresenterById("ui-mediaeditor:image");

    try {/*from   www  .ja  v  a  2  s .co m*/
        this.inputStream = new FileInputStream(file);
        this.view.setMediaEditor(mediaEditorPresenter.start(inputStream));
        this.mediaEditorPresenter.addCompletionHandler(handler);
    } catch (FileNotFoundException e) {
        log.warn("File not found: " + e.getMessage(), e);
        getSubAppContext().close();
    }
    return view;
}

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

/**
 * Gets the text from file content /*from  w  w w.ja  v a2s . c  om*/
 * @param file
 * @param fileExtension
 * @return
 */
@Override
public String getText(File file, String fileExtension) {
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(file);
    } catch (FileNotFoundException e) {
        LOGGER.info("File " + file.getName() + " not found. " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
        return null;
    }
    try {
        XLSTextStripper stripper = new XLSTextStripper(fis, fileExtension);
        return stripper.getText();
    } catch (Exception e) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(
                    "Extracting text from the .xls  file " + file.getName() + " failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        return null;
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
                LOGGER.debug("Closing the file input stream failed with " + e.getMessage());
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
    }
}

From source file:eu.europa.ec.markt.dss.signature.StreamDocument.java

@Override
public InputStream openStream() throws DSSException {
    logger.debug("");
    try {//from w  ww  .jav a2 s .co  m
        return getTemporaryFileAsStream();
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage());
        throw new DSSException(e);
    }
}

From source file:com.amalto.core.servlet.LogViewerServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    String location = config.getInitParameter("logFile"); //$NON-NLS-1$
    try {//w  w  w .  java2 s .  c o  m
        file = getLogFile(location);
    } catch (FileNotFoundException e) {
        throw new ServletException(e.getMessage(), e);
    }

    String defaultMaxLinesString = config.getInitParameter("maxLinesByChunk"); //$NON-NLS-1$
    defaultMaxLines = Integer.parseInt(defaultMaxLinesString);
    charset = config.getInitParameter("charset"); //$NON-NLS-1$
    if (charset == null) {
        charset = Charset.defaultCharset().name();
    }
}

From source file:eu.europa.ec.markt.dss.signature.StreamDocument.java

@Override
public String getDigest(DigestAlgorithm digestAlgorithm) {
    logger.debug("Digest algorithm: " + digestAlgorithm);
    byte[] digestBytes;
    try {/*from w w w .  j a v  a 2 s .com*/
        digestBytes = DSSUtils.digest(digestAlgorithm, getTemporaryFileAsStream());
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage());
        throw new DSSException(e);
    }
    return DSSUtils.base64Encode(digestBytes);
}

From source file:ait.ffma.service.preservation.riskmanagement.api.riskanalysis.risk.RiskUtils.java

/**
 * This method loads properties from property file.
 *//*from w w  w  . j a  v  a 2s.com*/
private static void loadProperties() {
    // load general properties
    generalProps = new Properties();
    InputStream in = null;
    try {
        try {
            in = RiskUtils.class.getResourceAsStream(RiskUtils.generalPropertiesFile);
            generalProps.load(in);
            in.close();
        } finally {
            in.close();
        }
    } catch (FileNotFoundException e) {
        LOG.log(Level.SEVERE, "File not found! " + e.getMessage());
    } catch (IOException e) {
        LOG.log(Level.SEVERE, "General properties could not be loaded! " + e.getMessage());
    }
    // load risk properties
    riskProps = new Properties();
    try {
        try {
            in = RiskUtils.class.getResourceAsStream(RiskUtils.riskPropertiesFile);
            riskProps.load(in);
            in.close();
        } finally {
            in.close();
        }
    } catch (FileNotFoundException e) {
        LOG.log(Level.SEVERE, "File not found! " + e.getMessage());
    } catch (IOException e) {
        LOG.log(Level.SEVERE, "Risk properties could not be loaded! " + e.getMessage());
    }
}

From source file:com.cws.esolutions.core.utils.EmailUtilsTest.java

@Test
public void sendEmailMessageWithAttachment() {
    try {//from  w ww .  j  a v  a 2  s. co m
        Map<String, InputStream> attachments = new HashMap<String, InputStream>() {
            private static final long serialVersionUID = 1L;

            {
                put("myFile", new FileInputStream(FileUtils.getFile("C:/temp", "myFile")));
            }
        };

        EmailMessage message = new EmailMessage();
        message.setIsAlert(false);
        message.setMessageSubject("Test Message");
        message.setMessageBCC(new ArrayList<String>(Arrays.asList("cws-khuntly")));
        message.setMessageCC(new ArrayList<String>(Arrays.asList("cws-khuntly")));
        message.setMessageTo(new ArrayList<String>(Arrays.asList("cws-khuntly")));
        message.setEmailAddr(new ArrayList<String>(Arrays.asList("cws-khuntly")));
        message.setMessageBody("This is a test message");
        message.setMessageAttachments(attachments);

        EmailUtils.sendEmailMessage(EmailUtilsTest.bean.getConfigData().getMailConfig(), message, false);
    } catch (MessagingException mx) {
        Assert.fail(mx.getMessage());
    } catch (FileNotFoundException fnfx) {
        Assert.fail(fnfx.getMessage());
    }
}

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

/**
 * Gets the text from file content //from   w  w w  .jav a2 s . c om
 * @param file
 * @param fileExtension
 * @return
 */
@Override
public String getText(File file, String fileExtension) {
    FileInputStream fis = null;
    XWPFWordExtractor ex = null;
    try {
        fis = new FileInputStream(file);
        XWPFDocument doc = new XWPFDocument(fis);
        if (doc != null) {
            ex = new XWPFWordExtractor(doc);
            return ex.getText();
        }
    } catch (FileNotFoundException e) {
        LOGGER.info("File " + file.getName() + " not found. " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } catch (Exception e) {
        LOGGER.debug("Extracting text from the .doc file " + file.getName() + " failed with " + e.getMessage());
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    } finally {
        try {
            if (fis != null) {
                fis.close();
            }
        } catch (IOException e) {
            LOGGER.debug("Closing the FileInputStream for file " + file.getName() + " failed with "
                    + e.getMessage());
            LOGGER.error(ExceptionUtils.getStackTrace(e));
        }
        if (ex != null) {
            try {
                ex.close();
            } catch (IOException e) {
                LOGGER.debug("Closing the text extractor from the .docx file " + file.getName()
                        + " failed with " + e.getMessage());
                LOGGER.error(ExceptionUtils.getStackTrace(e));
            }
        }
    }
    return null;
}