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:cloud.elasticity.elastman.Props.java

public static void save(String filename) {
    properties.setProperty("username", username);
    properties.setProperty("password", password);
    properties.setProperty("keyname", keyname);
    properties.setProperty("zone", zone);
    properties.setProperty("endpoint", endpoint);
    properties.setProperty("webSyncServer", webSyncServer);
    properties.setProperty("server.port", "" + server_port);
    properties.setProperty("ident.client.min", "" + ident_client_min);
    properties.setProperty("ident.client.max", "" + ident_client_max);
    properties.setProperty("ident.client.delta", "" + ident_client_delta);
    properties.setProperty("ident.client.delay", "" + ident_client_delay);
    properties.setProperty("ident.period", "" + ident_period);
    properties.setProperty("ident.sampling", "" + ident_sampling);
    properties.setProperty("ident.client.manual", "" + ident_client_manual);
    properties.setProperty("control.interval", "" + control_interval);
    properties.setProperty("cloud.voldVMs", "" + voldCount);
    properties.setProperty("act.createVMs", "" + createVMs);
    properties.setProperty("act.voldMax", "" + voldMax);
    properties.setProperty("act.voldMin", "" + voldMin);
    properties.setProperty("act.voldDeltaMax", "" + voldDeltaMax);

    properties.setProperty("control.kp", "" + control_kp);
    properties.setProperty("control.ki", "" + control_ki);
    properties.setProperty("control.kd", "" + control_kd);

    properties.setProperty("control.inOp", "" + control_inOp);
    properties.setProperty("control.outOp", "" + control_outOp);

    properties.setProperty("filter.alpha", "" + filter_alpha);
    properties.setProperty("control.warmup", "" + control_warmup);
    properties.setProperty("control.dead", "" + control_dead);
    properties.setProperty("control.ff.throughputDelta", "" + control_ff_throughputDelta);

    properties.setProperty("control.ff.r1", "" + control_ffr1);
    properties.setProperty("control.ff.w1", "" + control_ffw1);
    properties.setProperty("control.ff.r2", "" + control_ffr2);
    properties.setProperty("control.ff.w2", "" + control_ffw2);

    properties.setProperty("voldPrefix", voldPrefix);
    properties.setProperty("voldImage", voldImage);
    properties.setProperty("voldFlavor", voldFlavor);
    properties.setProperty("voldReplicationFactor", "" + voldReplicationFactor);
    properties.setProperty("ycsbPrefix", ycsbPrefix);
    properties.setProperty("ycsbImage", ycsbImage);
    properties.setProperty("ycsbFlavor", ycsbFlavor);

    //      properties.setProperty(, ""+);
    //      properties.setProperty(, ""+);
    //      properties.setProperty(, ""+);
    //      properties.setProperty(, ""+);
    //      properties.setProperty(, ""+);

    FileOutputStream propFile;//www. ja v  a 2  s .  c om
    try {
        propFile = new FileOutputStream(filename);
        properties.store(propFile, "ElastMan Configurations File");
    } catch (FileNotFoundException e) {
        log.error(e.getMessage());
        e.printStackTrace();
    } catch (IOException e) {
        log.error(e.getMessage());
        e.printStackTrace();
    }

}

From source file:de.sub.goobi.helper.FilesystemHelper.java

/**
 * Delete sym link./*from   ww  w .j a  va  2s.  co m*/
 *
 * @param symLink
 *            String
 */
public static void deleteSymLink(String symLink) {
    String command = ConfigCore.getParameter("script_deleteSymLink");
    ShellScript deleteSymLinkScript;
    try {
        deleteSymLinkScript = new ShellScript(new File(command));
        deleteSymLinkScript.run(Arrays.asList(new String[] { symLink }));
    } catch (FileNotFoundException e) {
        logger.error("FileNotFoundException in deleteSymLink()", e);
        Helper.setFehlerMeldung("Couldn't find script file, error", e.getMessage());
    } catch (IOException e) {
        logger.error("IOException in deleteSymLink()", e);
        Helper.setFehlerMeldung("Aborted deleteSymLink(), error", e.getMessage());
    }
}

From source file:com.testmax.util.FileUtility.java

public static void copyFile(String srFile, String dtFile) {
    try {/*from w w w  . jav a  2  s  .  co  m*/
        File f1 = new File(srFile);
        File f2 = new File(dtFile);
        InputStream in = new FileInputStream(f1);
        OutputStream out = new FileOutputStream(f2);

        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        in.close();
        out.close();

    } catch (FileNotFoundException ex) {
        WmLog.getCoreLogger().info(ex.getMessage() + " in the specified directory.");
        System.out.println(ex.getMessage() + " in the specified directory.");
    } catch (IOException e) {
        WmLog.getCoreLogger().info(e.getMessage());
        System.out.println(e.getMessage());
    }
}

From source file:edu.cornell.med.icb.goby.modes.CountsArchiveToUnionPeaksAnnotationMode.java

public static void writeAnnotations(final String outputFileName, final ObjectList<Annotation> annotationList,
        final boolean append) {
    final File outputFile = new File(outputFileName);
    PrintWriter writer = null;/*  ww w .  j  a va 2 s  .co m*/
    try {
        if (!outputFile.exists()) {
            writer = new PrintWriter(outputFile);
            writer.write(
                    "Chromosome_Name\tStrand\tPrimary_ID\tSecondary_ID\tTranscript_Start\tTranscript_End\n");
        } else {
            writer = new PrintWriter(new FileOutputStream(outputFile, append));
        }

        final ObjectListIterator<Annotation> annotIterator = annotationList.listIterator();
        while (annotIterator.hasNext()) {
            final Annotation annotation = annotIterator.next();
            annotation.write(writer);
        }
    } catch (FileNotFoundException fnfe) {
        System.err.println("Caught exception in writeAnnotations: " + fnfe.getMessage());
        System.exit(1);
    } finally {
        IOUtils.closeQuietly(writer);
    }
}

From source file:com.idiro.utils.db.mysql.MySqlUtils.java

public static boolean changeFormatAfterExport(File in, File out, char delimiter, Collection<String> header,
        Collection<String> quotes) {
    //We expect that in is a csv file and out a file
    boolean ok = true;
    FileChecker fChIn = new FileChecker(in), fChOut = new FileChecker(out);

    if (!fChIn.isFile()) {
        logger.error(fChIn.getFilename() + " is not a directory or does not exist");
        return false;
    }// w w w  .j a va2  s .co  m

    if (fChOut.exists()) {
        if (fChOut.isDirectory()) {
            logger.error(fChOut.getFilename() + " is a directory");
            return false;
        }
        logger.warn(fChOut.getFilename() + " already exists, it will be removed");
        String out_str = out.getAbsolutePath();
        out.delete();
        out = new File(out_str);
    }

    BufferedWriter bw = null;
    BufferedReader br = null;

    try {
        bw = new BufferedWriter(new FileWriter(out));

        logger.debug("read the file" + in.getAbsolutePath());
        br = new BufferedReader(new FileReader(in));
        String strLine;
        if (header != null && !header.isEmpty()) {
            Iterator<String> it = header.iterator();
            String headerLine = it.next();
            while (it.hasNext()) {
                headerLine += delimiter + it.next();
            }
            bw.write(headerLine + "\n");
        }

        //Read File Line By Line
        while ((strLine = br.readLine()) != null) {
            bw.write(DataFileUtils.addQuotesToLine(
                    DataFileUtils.getCleanLine(strLine.replace(',', delimiter), delimiter, delimiter), quotes,
                    delimiter) + "\n");
        }
        br.close();

        bw.close();
    } catch (FileNotFoundException e1) {
        logger.error(e1.getCause() + " " + e1.getMessage());
        logger.error("Fail to read " + in.getAbsolutePath());
        ok = false;
    } catch (IOException e1) {
        logger.error("Error writting, reading on the filesystem from the directory" + fChIn.getFilename()
                + " to the file " + fChOut.getFilename());
        ok = false;
    }
    if (ok) {
        in.delete();
    }
    return ok;
}

From source file:ch.qos.logback.ext.spring.web.WebLogbackConfigurer.java

/**
 * Initialize Logback, including setting the web app root system property.
 *
 * @param servletContext the current ServletContext
 * @see org.springframework.web.util.WebUtils#setWebAppRootSystemProperty
 *//* w ww.ja va2  s. c  om*/
public static void initLogging(ServletContext servletContext) {
    // Expose the web app root system property.
    if (exposeWebAppRoot(servletContext)) {
        WebUtils.setWebAppRootSystemProperty(servletContext);
    }

    // Only perform custom Logback initialization in case of a config file.
    String location = servletContext.getInitParameter(CONFIG_LOCATION_PARAM);
    if (location != null) {
        // Perform actual Logback initialization; else rely on Logback's default initialization.
        try {
            // Resolve system property placeholders before potentially resolving real path.
            location = ServletContextPropertyUtils.resolvePlaceholders(location);
            // Return a URL (e.g. "classpath:" or "file:") as-is;
            // consider a plain file path as relative to the web application root directory.
            if (!ResourceUtils.isUrl(location)) {
                location = WebUtils.getRealPath(servletContext, location);
            }

            // Write log message to server log.
            servletContext.log("Initializing Logback from [" + location + "]");

            // Initialize
            LogbackConfigurer.initLogging(location);
        } catch (FileNotFoundException ex) {
            throw new IllegalArgumentException("Invalid 'logbackConfigLocation' parameter: " + ex.getMessage());
        } catch (JoranException e) {
            throw new RuntimeException("Unexpected error while configuring logback", e);
        }
    }

    //If SLF4J's java.util.logging bridge is available in the classpath, install it. This will direct any messages
    //from the Java Logging framework into SLF4J. When logging is terminated, the bridge will need to be uninstalled
    try {
        Class<?> julBridge = ClassUtils.forName("org.slf4j.bridge.SLF4JBridgeHandler",
                ClassUtils.getDefaultClassLoader());

        Method removeHandlers = ReflectionUtils.findMethod(julBridge, "removeHandlersForRootLogger");
        if (removeHandlers != null) {
            servletContext.log("Removing all previous handlers for JUL to SLF4J bridge");
            ReflectionUtils.invokeMethod(removeHandlers, null);
        }

        Method install = ReflectionUtils.findMethod(julBridge, "install");
        if (install != null) {
            servletContext.log("Installing JUL to SLF4J bridge");
            ReflectionUtils.invokeMethod(install, null);
        }
    } catch (ClassNotFoundException ignored) {
        //Indicates the java.util.logging bridge is not in the classpath. This is not an indication of a problem.
        servletContext.log("JUL to SLF4J bridge is not available on the classpath");
    }
}

From source file:com.hoccer.tools.TestHelper.java

/**
 * Assert two {@linkplain File files} to have equal content.
 * //  w ww.  j av  a 2  s.c  o  m
 * @param message
 *            the error message
 * @param expected
 *            reference file
 * @param current
 *            file to compare
 * @author Apache Project (package org.apache.commons.id.test)
 * @license Apache Lichense 2.0
 */
public static void assertFileEquals(final String message, final File expected, final File current) {
    try {
        assertInputStreamEquals(new BufferedInputStream(new FileInputStream(expected)),
                new BufferedInputStream(new FileInputStream(current)));
    } catch (final FileNotFoundException e) {
        Assert.fail((message != null ? message + ": " : "") + e.getMessage());
    }
}

From source file:io.hawkcd.core.config.Config.java

public static String loadConfiguration(File configFile) {
    String errorMessage = "";

    try (FileInputStream fileInputStream = new FileInputStream(configFile)) {
        Yaml yaml = new Yaml();
        configuration = yaml.loadAs(fileInputStream, Configuration.class);

    } catch (FileNotFoundException e) {
        errorMessage = String.format(ConfigurationConstants.FAILED_TO_LOCATE_CONFIG, configFile.getName());
    } catch (YAMLException e) {
        errorMessage = e.getMessage();
        String pattern = "property=(.*?)\\s";
        Pattern regex = Pattern.compile(pattern);
        Matcher matcher = regex.matcher(errorMessage);
        if (matcher.find()) {
            errorMessage = String.format(ConfigurationConstants.INVALID_CONFIG_PROPERTY, matcher.group(1));
        }/*from www  . j a v a  2 s  . c  o m*/
    } catch (IOException e) {
        e.printStackTrace();
    }

    return errorMessage;
}

From source file:com.yodlee.sampleapps.helper.OpenSamlHelper.java

/**
 * Initilize the Keystore./*from   w  ww  . ja  v a2 s .  c o m*/
 */
private static void initKeyStore() {
    InputStream fileInput = null;
    try {
        fileInput = new FileInputStream(keystoreFilename);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
    KeyStore keystore = null;
    try {
        keystore = KeyStore.getInstance(KeyStore.getDefaultType());
        keystore.load(fileInput, keystorePassword.toCharArray());
        privateKey = (PrivateKey) keystore.getKey(keystoreAlias, keystorePassword.toCharArray());
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }

    if (privateKey == null)
        throw new RuntimeException(keystoreAlias + " key not found in keystore " + keystoreFilename);

    X509Certificate cert = null;
    Certificate[] certificates = new Certificate[0];
    try {
        cert = (X509Certificate) keystore.getCertificate(keystoreAlias);
        certificates = keystore.getCertificateChain(keystoreAlias);
    } catch (KeyStoreException e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
    if (cert == null)
        throw new RuntimeException(keystoreAlias + " cert not found in keystore " + keystoreFilename);

    if (certificates == null)
        throw new RuntimeException(keystoreAlias + " cert chain not found in keystore " + keystoreFilename);

    certs = new X509Certificate[certificates.length];
    System.arraycopy(certificates, 0, certs, 0, certs.length);
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.util.ExcelUtils.java

/**
 * @param filename/*  w  ww . ja  v  a 2s. c  om*/
 * 
 * @return the {@link Workbook}.
 * 
 * @throws IteraplanTechnicalException if opening the file failed for any reason.
 */
public static Workbook openExcelFile(String filename) {
    try {
        InputStream in = new FileInputStream(filename);
        return openExcelFile(in);
    } catch (FileNotFoundException e) {
        String msg = MessageFormat.format("Error opening file {0}: {1}", filename, e.getMessage());
        LOGGER.error(msg);
        throw new IteraplanTechnicalException(IteraplanErrorMessages.GENERAL_TECHNICAL_ERROR, msg);
    }
}