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.googlecode.t7mp.steps.deployment.WebappsDeploymentStep.java

@Override
protected void deployArtifacts(List<AbstractArtifact> artifactList) {
    for (AbstractArtifact artifact : artifactList) {
        final WebappArtifact webappArtifact = (WebappArtifact) artifact;
        if (webappArtifact.isUnpack() || webappArtifact.getTestContextFile() != null) {
            unzipWebappArtifact(webappArtifact);
            if (webappArtifact.getTestContextFile() != null) {
                File metaInfDirectory = new File(createTargetFileName(webappArtifact) + "/META-INF");
                metaInfDirectory.mkdirs();
                try {
                    IOUtils.copy(new FileInputStream(webappArtifact.getTestContextFile()),
                            new FileOutputStream(new File(metaInfDirectory, "context.xml")));
                } catch (FileNotFoundException e) {
                    throw new TomcatSetupException(e.getMessage(), e);
                } catch (IOException e) {
                    throw new TomcatSetupException(e.getMessage(), e);
                }//from  w  w w.j ava  2  s. c  om
            }
        } else {
            try {
                String targetFileName = createTargetFileName(artifact);
                File sourceFile = artifact.getArtifact().getFile();
                File targetFile = new File(this.context.getMojo().getCatalinaBase(),
                        "/webapps/" + targetFileName);
                this.context.getLog().debug("Copy artifact from " + sourceFile.getAbsolutePath() + " to "
                        + targetFile.getAbsolutePath());
                this.setupUtil.copy(new FileInputStream(sourceFile), new FileOutputStream(targetFile));
            } catch (IOException e) {
                throw new TomcatSetupException(e.getMessage(), e);
            }
        }
    }
}

From source file:com.googlecode.t7mp.steps.WebappsDeploymentStep.java

@Override
protected void deployArtifacts(List<AbstractArtifact> artifactList) {
    for (AbstractArtifact artifact : artifactList) {
        final WebappArtifact webappArtifact = (WebappArtifact) artifact;
        if (webappArtifact.isUnpack() || webappArtifact.getTestContextFile() != null) {
            unzipWebappArtifact(webappArtifact);
            if (webappArtifact.getTestContextFile() != null) {
                File metaInfDirectory = new File(createTargetFileName(webappArtifact) + "/META-INF");
                metaInfDirectory.mkdirs();
                try {
                    IOUtils.copy(new FileInputStream(webappArtifact.getTestContextFile()),
                            new FileOutputStream(new File(metaInfDirectory, "context.xml")));
                } catch (FileNotFoundException e) {
                    throw new TomcatSetupException(e.getMessage(), e);
                } catch (IOException e) {
                    throw new TomcatSetupException(e.getMessage(), e);
                }/*from  ww  w.  j  a  va2 s.c o m*/
            }
        } else {
            try {
                String targetFileName = createTargetFileName(artifact);
                File sourceFile = artifact.getFile();
                File targetFile = new File(this.context.getConfiguration().getCatalinaBase(),
                        "/webapps/" + targetFileName);
                this.context.getLog().debug("Copy artifact from " + sourceFile.getAbsolutePath() + " to "
                        + targetFile.getAbsolutePath());
                this.setupUtil.copy(new FileInputStream(sourceFile), new FileOutputStream(targetFile));
            } catch (IOException e) {
                throw new TomcatSetupException(e.getMessage(), e);
            }
        }
    }
}

From source file:org.apache.zeppelin.helium.HeliumOnlineRegistry.java

private List<HeliumPackage> readFromCache() {
    synchronized (registryCacheFile) {
        if (registryCacheFile.isFile()) {
            try {
                return gson.fromJson(new FileReader(registryCacheFile), new TypeToken<List<HeliumPackage>>() {
                }.getType());//  w  ww  .ja v  a  2  s .co  m
            } catch (FileNotFoundException e) {
                logger.error(e.getMessage(), e);
                return new LinkedList<>();
            }
        } else {
            return new LinkedList<>();
        }
    }
}

From source file:net.fizzl.redditengine.impl.PersistentCookieStore.java

/**
 * Load Cookies from a file//w w w.ja  v  a2 s . co  m
 */
private void load() {
    RedditApi api = DefaultRedditApi.getInstance();
    Context ctx = api.getContext();
    try {
        FileInputStream fis = ctx.openFileInput(cookiestore);
        ObjectInputStream ois = new ObjectInputStream(fis);
        SerializableCookieStore tempStore = (SerializableCookieStore) ois.readObject();

        super.clear();
        for (Cookie c : tempStore.getCookies()) {
            super.addCookie(c);
        }

        ois.close();
        fis.close();
    } catch (FileNotFoundException e) {
        Log.w(getClass().getName(), e.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ImageUploader.java

@Override
public OutputStream receiveUpload(String filename, String mimeType) {
    if (filename == null) {
        return null;
    }//from   ww w .j  av a2  s.  c o m
    // Create upload stream
    FileOutputStream fos; // Stream to write to
    try {

        fileService.createBasicFolders();
        file = fileService.createFile(Constants.BASE_PATH + securityHelper.getLogedInUser().getId() + "-"
                + Math.abs((int) (Math.random() * 10000000)) + "." + FilenameUtils.getExtension(filename));
        if (file == null) {
            Notification.show(msgs.getMessage("error.file.exists"), Notification.Type.ERROR_MESSAGE);
            return null;
        }
        fos = new FileOutputStream(file);

    } catch (final java.io.FileNotFoundException e) {
        logger.error(e.getMessage(), e);
        return null;
    } catch (SecurityException e) {
        logger.error(e.getMessage(), e);
        return null;

    }
    return fos; // Return the output stream to write to
}

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

/**
 * Gets the text from file content //from w w w.  ja va  2 s  .com
 * @param file
 * @param fileExtension
 * @return
 */
@Override
public String getText(File file, String fileExtension) {
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(file);
        WordTextExtractorFactory wordTextExtractorFactory = new WordTextExtractorFactory();
        return wordTextExtractorFactory.textExtractor(fis).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));
        }
    }
    return null;
}

From source file:com.buildml.main.commands.CliCommandUpgrade.java

@Override
public void invoke(IBuildStore buildStore, String buildStorePath, String[] args) {

    CliUtils.validateArgs(getName(), args, 0, 0,
            "No arguments required. Use -f global option to specify database name.");

    /* all is good */
    try {/*w w w.  jav a  2s . c o  m*/
        BuildStoreFactory.upgradeBuildStore(buildStorePath);
    } catch (FileNotFoundException e) {
        CliUtils.reportErrorAndExit(e.getMessage());
    } catch (BuildStoreVersionException e) {
        CliUtils.reportErrorAndExit(e.getMessage());
    }

    System.out.println("Database is now at correct schema version.");
}

From source file:com.jbrisbin.vpc.jobsched.patch.PatchMessageHandler.java

public void handleMessage(final PatchMessage msg) {

    if (null != msg.getFile()) {
        // Read original file
        List<String> original = new ArrayList<String>();
        File originalFile = new File(msg.getFile());
        try {/*  w  ww. ja  v a 2  s.c  om*/
            BufferedReader reader = new BufferedReader(new FileReader(originalFile));
            String line = null;
            while (null != (line = reader.readLine())) {
                original.add(line);
            }
            reader.close();
        } catch (FileNotFoundException e) {
            log.error(e.getMessage(), e);
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
        if (log.isDebugEnabled()) {
            log.debug("Patching original file: " + original);
        }

        // Patch it
        Patch patch = DiffUtils.parseUnifiedDiff(msg.getDiff());
        try {
            List<String> updated = (List<String>) DiffUtils.patch(original, patch);
            File tmp = File.createTempFile("patcher_", "patched");
            BufferedWriter writer = new BufferedWriter(new FileWriter(tmp));
            for (String line : updated) {
                writer.write(line + "\n");
            }
            writer.flush();
            writer.close();

            // Backup existing file
            File basedir = originalFile.getParentFile();
            if (basedir.canWrite()) {
                File backup = new File(originalFile.getParentFile(),
                        originalFile.getName() + ".bkp." + fmt.format(Calendar.getInstance().getTime()));
                originalFile.renameTo(backup);
                // Replace with patched version
                tmp.renameTo(originalFile);
            }

        } catch (PatchFailedException e) {
            log.error(e.getMessage(), e);
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
    }

}

From source file:com.mondora.chargify.ChargifyFactory.java

public BeanFactory getFactory() {
    if (factory == null) {
        try {//from   ww  w . j a va  2  s. com
            factory = readFromSenseDirConf();
        } catch (FileNotFoundException e) {
            if (logger.isDebugEnabled())
                logger.debug(e.getMessage());
            factory = defaultFactory();
        }
    }
    return factory;
}

From source file:com.group7.dragonwars.tests.GameMapTests.java

private List<String> readFile(final String filename) {
    List<String> text = new ArrayList<String>();

    try {//w  w  w.  j av a  2 s. c o  m
        BufferedReader in = new BufferedReader(new FileReader(filename));
        String line;

        while ((line = in.readLine()) != null) {
            text.add(line);
        }

        in.close();
    } catch (FileNotFoundException fnf) {
        System.err.println("Couldn't find " + fnf.getMessage());
        System.exit(1);
    } catch (IOException ioe) {
        System.err.println("Couldn't read " + ioe.getMessage());
        System.exit(1);
    }

    return text;
}