Examples of FileUtil


Examples of xplanetconfigurator.util.FileUtil

        String dirInClasspath = "/xplanetconfigurator/gui/resources/examples/";
        String fileInClasspath = dirInClasspath + filename;
        String msg = "Reading downloader config file from classpath (jar):\n" + fileInClasspath + "'";
        this.logger.finer(msg);
        String fileContent = null;
        FileUtil util = new FileUtil();
        try {
            fileContent = util.getRessourceAsString(fileInClasspath);
        } catch (Exception ex) {
            msg = ex + "\nFailed to: " + msg;
            this.logger.log(Level.SEVERE, "Failed to do: " + msg, ex);
            this.popError(msg);
        }
View Full Code Here

Examples of xplanetconfigurator.util.FileUtil

        // Remove all lines from downloader
        this.removeLinesFromDownloader(regExpressionToRemove);

        // Insert the file content into the downloader
        // First get the file content from the file in the jar
        FileUtil util = new FileUtil();
        String fileInClasspath = "/xplanetconfigurator/gui/resources/examples/" + fileToInsert;
        String msg = "Reading file content from jar file.\nFile is:\n" + fileInClasspath;
        String fileContent = "";
        try {
            fileContent = util.getRessourceAsString(fileInClasspath);
        } catch (Exception ex) {
            this.logger.log(Level.SEVERE, "Failed to do: " + msg, ex);
            this.popError(msg);
            return;
        }
View Full Code Here

Examples of xplanetconfigurator.util.FileUtil

                logger.finer("Did not found logging configuratin file: " + file);
            }
        }
       
        // Find in classpath
        FileUtil fileUtil = new FileUtil();
        String fileInClasspath = "/xplanetconfigurator/util/logging/" + LoggingInitializer.FILE_NAME;
        String fileContent = null;
        logger.finer("Try to read logging configuration from file: '" + fileInClasspath + "'...");
        try {
            fileContent = fileUtil.getRessourceAsString(fileInClasspath);
        } catch(Exception e) {
            logger.warning("Could not read file from classpath. File: '" + fileInClasspath + "'");
        }
        String userHome = System.getProperty("user.home");
        String defaultConfigFileLocation = userHome + File.separator + LoggingInitializer.FILE_NAME;
        if(fileContent != null)
        {
            logger.finer("Reading file content to file: '" + defaultConfigFileLocation + "'...");
            try {
                fileUtil.printFile(defaultConfigFileLocation, fileContent);
                return defaultConfigFileLocation;
            } catch(Exception e) {
                logger.warning("Failed to write file: '" + defaultConfigFileLocation + "'");
            }
        }
       
        // Try to read from java.home/jre/lib
        String javaHome = System.getProperty("java.home");
        String fileInJavaHome =
            javaHome + File.separator + "jre" + File.separator + "lib" + LoggingInitializer.FILE_NAME;
        try {
            fileContent = fileUtil.getFileAsString(new File(fileInJavaHome));
        } catch(Exception e) {
            logger.warning("Could not read file from classpath. File: '" + fileInClasspath + "'");
        }
        if(fileContent != null)
        {
            logger.finer("Reading file content to file: '" + defaultConfigFileLocation + "'...");
            try {
                fileUtil.printFile(defaultConfigFileLocation, fileContent);
                return defaultConfigFileLocation;
            } catch(Exception e) {
                logger.warning("Failed to write file: '" + defaultConfigFileLocation + "'");
            }
        }
View Full Code Here

Examples of xplanetconfigurator.util.FileUtil

        }
        if (!f.canRead()) {
            this.logger.warning("Not allowed to read configuration file: " + file);
            return;
        }
        FileUtil util = new FileUtil();
        try {
            this.configFileContent = util.getFileAsString(f);
        } catch (Exception ex) {
            this.logger.log(Level.SEVERE, null, ex);
            return;
        }
View Full Code Here

Examples of xplanetconfigurator.util.FileUtil

    /**
     * Writes the configuration to file
     */
    public void saveConfiguration() {
        FileUtil util = new FileUtil();
        try {
            util.printFile(this.configFile, this.configFileContent);
        } catch (Exception ex) {
            this.logger.log(Level.SEVERE, null, ex);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.