Example usage for java.io File getAbsolutePath

List of usage examples for java.io File getAbsolutePath

Introduction

In this page you can find the example usage for java.io File getAbsolutePath.

Prototype

public String getAbsolutePath() 

Source Link

Document

Returns the absolute pathname string of this abstract pathname.

Usage

From source file:de.alpharogroup.phone.data.management.system.ApplicationJettyRunner.java

/**
 * The main method starts a jetty server with the rest services for the resource-bundle-data.
 *
 * @param args/*ww w  . j a va  2  s  .co  m*/
 *            the arguments
 * @throws Exception
 *             the exception
 */
public static void main(final String[] args) throws Exception {
    final int sessionTimeout = 1800;// set timeout to 30min(60sec *
    // 30min=1800sec)...
    final String projectname = getProjectName();
    final File projectDirectory = PathFinder.getProjectDirectory();
    final File webapp = PathFinder.getRelativePath(projectDirectory, projectname, "src", "main", "webapp");

    final String filterPath = "/*";

    final File logfile = new File(projectDirectory, "application.log");
    if (logfile.exists()) {
        try {
            DeleteFileExtensions.delete(logfile);
        } catch (final IOException e) {
            Logger.getRootLogger().error("logfile could not deleted.", e);
        }
    }
    // Add a file appender to the logger programatically
    LoggerExtensions.addFileAppender(Logger.getRootLogger(),
            LoggerExtensions.newFileAppender(logfile.getAbsolutePath()));

    final ServletContextHandler servletContextHandler = ServletContextHandlerFactory
            .getNewServletContextHandler(ServletContextHandlerConfiguration.builder()
                    .servletHolderConfiguration(ServletHolderConfiguration.builder()
                            .servletClass(CXFServlet.class).pathSpec(filterPath).build())
                    .contextPath("/").webapp(webapp).maxInactiveInterval(sessionTimeout).filterPath(filterPath)
                    .initParameter("contextConfigLocation", "classpath:application-context.xml").build());
    servletContextHandler.addEventListener(new ContextLoaderListener());
    final Jetty9RunConfiguration configuration = Jetty9RunConfiguration.builder()
            .servletContextHandler(servletContextHandler).httpPort(11080).httpsPort(11443).build();
    final Server server = new Server();
    Jetty9Runner.runServletContextHandler(server, configuration);

}

From source file:de.burlov.amazon.s3.dirsync.CLI.java

/**
 * @param args//  ww  w .j  a va  2  s  . c  o m
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    Logger.getLogger("").setLevel(Level.OFF);
    Logger deLogger = Logger.getLogger("de");
    deLogger.setLevel(Level.INFO);
    Handler handler = new ConsoleHandler();
    handler.setFormatter(new VerySimpleFormatter());
    deLogger.addHandler(handler);
    deLogger.setUseParentHandlers(false);
    //      if (true)
    //      {
    //         LogFactory.getLog(CLI.class).error("test msg", new Exception("test extception"));
    //         return;
    //      }
    Options opts = new Options();
    OptionGroup gr = new OptionGroup();

    /*
     * Befehlsgruppe initialisieren
     */
    gr = new OptionGroup();
    gr.setRequired(true);
    gr.addOption(OptionBuilder.withArgName("up|down").hasArg()
            .withDescription("Upload/Download changed or new files").create(CMD_UPDATE));
    gr.addOption(OptionBuilder.withArgName("up|down").hasArg()
            .withDescription("Upload/Download directory snapshot").create(CMD_SNAPSHOT));
    gr.addOption(OptionBuilder.withDescription("Delete remote folder").create(CMD_DELETE_DIR));
    gr.addOption(OptionBuilder.withDescription("Delete a bucket").create(CMD_DELETE_BUCKET));
    gr.addOption(OptionBuilder.create(CMD_HELP));
    gr.addOption(OptionBuilder.create(CMD_VERSION));
    gr.addOption(OptionBuilder.withDescription("Prints summary for stored data").create(CMD_SUMMARY));
    gr.addOption(OptionBuilder.withDescription("Clean up orphaned objekts").create(CMD_CLEANUP));
    gr.addOption(OptionBuilder.withDescription("Changes encryption password").withArgName("new password")
            .hasArg().create(CMD_CHANGE_PASSWORD));
    gr.addOption(OptionBuilder.withDescription("Lists all buckets").create(CMD_LIST_BUCKETS));
    gr.addOption(OptionBuilder.withDescription("Lists raw objects in a bucket").create(CMD_LIST_BUCKET));
    gr.addOption(OptionBuilder.withDescription("Lists files in remote folder").create(CMD_LIST_DIR));
    opts.addOptionGroup(gr);
    /*
     * Parametergruppe initialisieren
     */
    opts.addOption(OptionBuilder.withArgName("key").isRequired(false).hasArg().withDescription("S3 access key")
            .create(OPT_S3S_KEY));
    opts.addOption(OptionBuilder.withArgName("secret").isRequired(false).hasArg()
            .withDescription("Secret key for S3 account").create(OPT_S3S_SECRET));
    opts.addOption(OptionBuilder.withArgName("bucket").isRequired(false).hasArg().withDescription(
            "Optional bucket name for storage. If not specified then an unique bucket name will be generated")
            .create(OPT_BUCKET));
    // opts.addOption(OptionBuilder.withArgName("US|EU").hasArg().
    // withDescription(
    // "Where the new bucket should be created. Default US").create(
    // OPT_LOCATION));
    opts.addOption(OptionBuilder.withArgName("path").isRequired(false).hasArg()
            .withDescription("Local directory path").create(OPT_LOCAL_DIR));
    opts.addOption(OptionBuilder.withArgName("name").isRequired(false).hasArg()
            .withDescription("Remote directory name").create(OPT_REMOTE_DIR));
    opts.addOption(OptionBuilder.withArgName("password").isRequired(false).hasArg()
            .withDescription("Encryption password").create(OPT_ENC_PASSWORD));
    opts.addOption(OptionBuilder.withArgName("patterns").hasArgs()
            .withDescription("Comma separated exclude file patterns like '*.tmp,*/dir/*.tmp'")
            .create(OPT_EXCLUDE_PATTERNS));
    opts.addOption(OptionBuilder.withArgName("patterns").hasArgs().withDescription(
            "Comma separated include patterns like '*.java'. If not specified, then all files in specified local directory will be included")
            .create(OPT_INCLUDE_PATTERNS));

    if (args.length == 0) {
        printUsage(opts);
        return;
    }

    CommandLine cmd = null;
    try {
        cmd = new GnuParser().parse(opts, args);
        if (cmd.hasOption(CMD_HELP)) {
            printUsage(opts);
            return;
        }
        if (cmd.hasOption(CMD_VERSION)) {
            System.out.println("s3dirsync version " + Version.CURRENT_VERSION);
            return;
        }
        String awsKey = cmd.getOptionValue(OPT_S3S_KEY);
        String awsSecret = cmd.getOptionValue(OPT_S3S_SECRET);
        String bucket = cmd.getOptionValue(OPT_BUCKET);
        String bucketLocation = cmd.getOptionValue(OPT_LOCATION);
        String localDir = cmd.getOptionValue(OPT_LOCAL_DIR);
        String remoteDir = cmd.getOptionValue(OPT_REMOTE_DIR);
        String password = cmd.getOptionValue(OPT_ENC_PASSWORD);
        String exclude = cmd.getOptionValue(OPT_EXCLUDE_PATTERNS);
        String include = cmd.getOptionValue(OPT_INCLUDE_PATTERNS);

        if (StringUtils.isBlank(awsKey) || StringUtils.isBlank(awsSecret)) {
            System.out.println("S3 account data required");
            return;
        }

        if (StringUtils.isBlank(bucket)) {
            bucket = awsKey + ".dirsync";
        }

        if (cmd.hasOption(CMD_DELETE_BUCKET)) {
            if (StringUtils.isBlank(bucket)) {
                System.out.println("Bucket name required");
                return;
            }
            int deleted = S3Utils.deleteBucket(awsKey, awsSecret, bucket);
            System.out.println("Deleted objects: " + deleted);
            return;
        }
        if (cmd.hasOption(CMD_LIST_BUCKETS)) {
            for (String str : S3Utils.listBuckets(awsKey, awsSecret)) {
                System.out.println(str);
            }
            return;
        }
        if (cmd.hasOption(CMD_LIST_BUCKET)) {
            if (StringUtils.isBlank(bucket)) {
                System.out.println("Bucket name required");
                return;
            }
            for (String str : S3Utils.listObjects(awsKey, awsSecret, bucket)) {
                System.out.println(str);
            }
            return;
        }
        if (StringUtils.isBlank(password)) {
            System.out.println("Encryption password required");
            return;
        }
        char[] psw = password.toCharArray();
        DirSync ds = new DirSync(awsKey, awsSecret, bucket, bucketLocation, psw);
        ds.setExcludePatterns(parseSubargumenths(exclude));
        ds.setIncludePatterns(parseSubargumenths(include));
        if (cmd.hasOption(CMD_SUMMARY)) {
            ds.printStorageSummary();
            return;
        }
        if (StringUtils.isBlank(remoteDir)) {
            System.out.println("Remote directory name required");
            return;
        }
        if (cmd.hasOption(CMD_DELETE_DIR)) {
            ds.deleteFolder(remoteDir);
            return;
        }
        if (cmd.hasOption(CMD_LIST_DIR)) {
            Folder folder = ds.getFolder(remoteDir);
            if (folder == null) {
                System.out.println("No such folder found: " + remoteDir);
                return;
            }
            for (Map.Entry<String, FileInfo> entry : folder.getIndexData().entrySet()) {
                System.out.println(entry.getKey() + " ("
                        + FileUtils.byteCountToDisplaySize(entry.getValue().getLength()) + ")");
            }
            return;
        }
        if (cmd.hasOption(CMD_CLEANUP)) {
            ds.cleanUp();
            return;
        }
        if (cmd.hasOption(CMD_CHANGE_PASSWORD)) {
            String newPassword = cmd.getOptionValue(CMD_CHANGE_PASSWORD);
            if (StringUtils.isBlank(newPassword)) {
                System.out.println("new password required");
                return;
            }
            char[] chars = newPassword.toCharArray();
            ds.changePassword(chars);
            newPassword = null;
            Arrays.fill(chars, ' ');
            return;
        }
        if (StringUtils.isBlank(localDir)) {
            System.out.println(OPT_LOCAL_DIR + " argument required");
            return;
        }
        String direction = "";
        boolean up = false;
        boolean snapshot = false;
        if (StringUtils.isNotBlank(cmd.getOptionValue(CMD_UPDATE))) {
            direction = cmd.getOptionValue(CMD_UPDATE);
        } else if (StringUtils.isNotBlank(cmd.getOptionValue(CMD_SNAPSHOT))) {
            direction = cmd.getOptionValue(CMD_SNAPSHOT);
            snapshot = true;
        }
        if (StringUtils.isBlank(direction)) {
            System.out.println("Operation direction required");
            return;
        }
        up = StringUtils.equalsIgnoreCase(OPT_UP, direction);
        File baseDir = new File(localDir);
        if (!baseDir.exists() && !baseDir.mkdirs()) {
            System.out.println("Invalid local directory: " + baseDir.getAbsolutePath());
            return;
        }
        ds.syncFolder(baseDir, remoteDir, up, snapshot);

    } catch (DirSyncException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        printUsage(opts);

    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}

From source file:act.installer.HMDBParser.java

public static void main(String[] args) throws Exception {
    // Parse the command line options
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());// w  ww .  j a v  a 2  s. com
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.err.format("Argument parsing failed: %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(PubchemParser.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(PubchemParser.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        return;
    }

    File inputDir = new File(cl.getOptionValue(OPTION_INPUT_DIRECTORY));
    if (!inputDir.isDirectory()) {
        System.err.format("Input directory at %s is not a directory\n", inputDir.getAbsolutePath());
        System.exit(1);
    }

    String dbName = cl.getOptionValue(OPTION_DB_NAME, DEFAULT_DB_NAME);
    String dbHost = cl.getOptionValue(OPTION_DB_HOST, DEFAULT_DB_HOST);
    Integer dbPort = Integer.valueOf(cl.getOptionValue(OPTION_DB_PORT, DEFAULT_DB_PORT));

    LOGGER.info("Connecting to %s:%d/%s", dbHost, dbPort, dbName);
    MongoDB db = new MongoDB(dbHost, dbPort, dbName);
    HMDBParser parser = Factory.makeParser(db);

    LOGGER.info("Starting parser");
    parser.run(inputDir);
    LOGGER.info("Done");
}

From source file:com.github.s4ke.moar.cli.Main.java

public static void main(String[] args) throws ParseException, IOException {
    // create Options object
    Options options = new Options();

    options.addOption("rf", true,
            "file containing the regexes to test against (multiple regexes are separated by one empty line)");
    options.addOption("r", true, "regex to test against");

    options.addOption("mf", true, "file/folder to read the MOA from");
    options.addOption("mo", true, "folder to export the MOAs to (overwrites if existent)");

    options.addOption("sf", true, "file to read the input string(s) from");
    options.addOption("s", true, "string to test the MOA/Regex against");

    options.addOption("m", false, "multiline matching mode (search in string for regex)");

    options.addOption("ls", false, "treat every line of the input string file as one string");
    options.addOption("t", false, "trim lines if -ls is set");

    options.addOption("d", false, "only do determinism check");

    options.addOption("help", false, "prints this dialog");

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);

    if (args.length == 0 || cmd.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("moar-cli", options);
        return;/*from  ww w  .java 2 s . com*/
    }

    List<String> patternNames = new ArrayList<>();
    List<MoaPattern> patterns = new ArrayList<>();
    List<String> stringsToCheck = new ArrayList<>();

    if (cmd.hasOption("r")) {
        String regexStr = cmd.getOptionValue("r");
        try {
            patterns.add(MoaPattern.compile(regexStr));
            patternNames.add(regexStr);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    if (cmd.hasOption("rf")) {
        String fileName = cmd.getOptionValue("rf");
        List<String> regexFileContents = readFileContents(new File(fileName));
        int emptyLineCountAfterRegex = 0;
        StringBuilder regexStr = new StringBuilder();
        for (String line : regexFileContents) {
            if (emptyLineCountAfterRegex >= 1) {
                if (regexStr.length() > 0) {
                    patterns.add(MoaPattern.compile(regexStr.toString()));
                    patternNames.add(regexStr.toString());
                }
                regexStr.setLength(0);
                emptyLineCountAfterRegex = 0;
            }
            if (line.trim().equals("")) {
                if (regexStr.length() > 0) {
                    ++emptyLineCountAfterRegex;
                }
            } else {
                regexStr.append(line);
            }
        }
        if (regexStr.length() > 0) {
            try {
                patterns.add(MoaPattern.compile(regexStr.toString()));
                patternNames.add(regexStr.toString());
            } catch (Exception e) {
                System.out.println(e.getMessage());
                return;
            }
            regexStr.setLength(0);
        }
    }

    if (cmd.hasOption("mf")) {
        String fileName = cmd.getOptionValue("mf");
        File file = new File(fileName);
        if (file.isDirectory()) {
            System.out.println(fileName + " is a directory, using all *.moar files as patterns");
            File[] moarFiles = file.listFiles(pathname -> pathname.getName().endsWith(".moar"));
            for (File moar : moarFiles) {
                String jsonString = readWholeFile(moar);
                patterns.add(MoarJSONSerializer.fromJSON(jsonString));
                patternNames.add(moar.getAbsolutePath());
            }
        } else {
            System.out.println(fileName + " is a single file. using it directly (no check for *.moar suffix)");
            String jsonString = readWholeFile(file);
            patterns.add(MoarJSONSerializer.fromJSON(jsonString));
            patternNames.add(fileName);
        }
    }

    if (cmd.hasOption("s")) {
        String str = cmd.getOptionValue("s");
        stringsToCheck.add(str);
    }

    if (cmd.hasOption("sf")) {
        boolean treatLineAsString = cmd.hasOption("ls");
        boolean trim = cmd.hasOption("t");
        String fileName = cmd.getOptionValue("sf");
        StringBuilder stringBuilder = new StringBuilder();
        boolean firstLine = true;
        for (String str : readFileContents(new File(fileName))) {
            if (treatLineAsString) {
                if (trim) {
                    str = str.trim();
                    if (str.length() == 0) {
                        continue;
                    }
                }
                stringsToCheck.add(str);
            } else {
                if (!firstLine) {
                    stringBuilder.append("\n");
                }
                if (firstLine) {
                    firstLine = false;
                }
                stringBuilder.append(str);
            }
        }
        if (!treatLineAsString) {
            stringsToCheck.add(stringBuilder.toString());
        }
    }

    if (cmd.hasOption("d")) {
        //at this point we have already built the Patterns
        //so just give the user a short note.
        System.out.println("All Regexes seem to be deterministic.");
        return;
    }

    if (patterns.size() == 0) {
        System.out.println("no patterns to check");
        return;
    }

    if (cmd.hasOption("mo")) {
        String folder = cmd.getOptionValue("mo");
        File folderFile = new File(folder);
        if (!folderFile.exists()) {
            System.out.println(folder + " does not exist. creating...");
            if (!folderFile.mkdirs()) {
                System.out.println("folder " + folder + " could not be created");
            }
        }
        int cnt = 0;
        for (MoaPattern pattern : patterns) {
            String patternAsJSON = MoarJSONSerializer.toJSON(pattern);
            try (BufferedWriter writer = new BufferedWriter(
                    new FileWriter(new File(folderFile, "pattern" + ++cnt + ".moar")))) {
                writer.write(patternAsJSON);
            }
        }
        System.out.println("stored " + cnt + " patterns in " + folder);
    }

    if (stringsToCheck.size() == 0) {
        System.out.println("no strings to check");
        return;
    }

    boolean multiline = cmd.hasOption("m");

    for (String string : stringsToCheck) {
        int curPattern = 0;
        for (MoaPattern pattern : patterns) {
            MoaMatcher matcher = pattern.matcher(string);
            if (!multiline) {
                if (matcher.matches()) {
                    System.out.println("\"" + patternNames.get(curPattern) + "\" matches \"" + string + "\"");
                } else {
                    System.out.println(
                            "\"" + patternNames.get(curPattern) + "\" does not match \"" + string + "\"");
                }
            } else {
                StringBuilder buffer = new StringBuilder(string);
                int additionalCharsPerMatch = ("<match>" + "</match>").length();
                int matchCount = 0;
                while (matcher.nextMatch()) {
                    buffer.replace(matcher.getStart() + matchCount * additionalCharsPerMatch,
                            matcher.getEnd() + matchCount * additionalCharsPerMatch,
                            "<match>" + string.substring(matcher.getStart(), matcher.getEnd()) + "</match>");
                    ++matchCount;
                }
                System.out.println(buffer.toString());
            }
        }
        ++curPattern;
    }
}

From source file:jhc.redsniff.generation.PackageScanningGenerator.java

public static void main(String[] args) throws Exception {

    if (args.length != 5) {
        System.err.println("Args: source-dir package-class-filter parent-class generated-class output-dir");
        System.err.println("");
        System.err.println("    source-dir  : Path to Java source containing matchers to generate sugar for.");
        System.err.println("                  May contain multiple paths, separated by commas.");
        System.err.println("                  e.g. src/java,src/more-java");
        System.err.println(//from  ww w .j a v  a 2  s.com
                "    package-class-filter  : base of package to look for classes with methods, eg jhc.selenium.matchers");

        System.err.println("");
        System.err.println(
                "parent-class : Full name of parent class type to examine - eg org.hamcrest.Matcher, jhc.selenium.seeker.Seeker");
        System.err.println("                  e.g. org.myproject.MyMatchers");
        System.err.println("generated-class : Full name of class to generate.");
        System.err.println("                  e.g. org.myproject.MyMatchers");
        System.err.println("");
        System.err.println("     output-dir : Where to output generated code (package subdirs will be");
        System.err.println("                  automatically created).");
        System.err.println("                  e.g. build/generated-code");
        System.exit(-1);
    }

    String srcDirs = args[0];
    String package_name_prefix = args[1];
    String parentClassName = args[2];
    String fullClassName = args[3];
    File outputDir = new File(args[4]);

    String fileName = fullClassName.replace('.', File.separatorChar) + ".java";
    int dotIndex = fullClassName.lastIndexOf(".");
    String packageName = dotIndex == -1 ? "" : fullClassName.substring(0, dotIndex);
    String shortClassName = fullClassName.substring(dotIndex + 1);

    if (!outputDir.isDirectory()) {
        System.err.println("Output directory not found : " + outputDir.getAbsolutePath());
        System.exit(-1);
    }

    Class<?> parentClass = Class.forName(parentClassName);

    File outputFile = new File(outputDir, fileName);
    outputFile.getParentFile().mkdirs();
    File tmpFile = new File(outputDir, fileName + ".tmp");

    SugarGenerator sugarGenerator = new SugarGenerator();
    try {
        sugarGenerator
                .addWriter(new SeleniumFactoryWriter(packageName, shortClassName, new FileWriter(tmpFile)));
        sugarGenerator.addWriter(new QuickReferenceWriter(System.out));

        PackageScanningGenerator pkgScanningGenerator = new PackageScanningGenerator(sugarGenerator,
                PackageScanningGenerator.class.getClassLoader(), parentClass);

        if (srcDirs.trim().length() > 0) {
            for (String srcDir : srcDirs.split(",")) {
                pkgScanningGenerator.addSourceDir(new File(srcDir));
            }
        }
        // could add use of xml just to list filter expressions
        // pkgScanningGenerator.load(new InputSource(configFile));
        pkgScanningGenerator.addClasses(package_name_prefix);

        System.out.println("Generating " + fullClassName);
        sugarGenerator.generate();
        sugarGenerator.close();
        outputFile.delete();
        FileUtils.moveFile(tmpFile, outputFile);

    } finally {
        tmpFile.delete();
        sugarGenerator.close();
    }
}

From source file:edu.oregonstate.eecs.mcplan.abstraction.PairDataset.java

/**
 * @param args//from w w w .  j  av  a  2  s.  co m
 */
public static void main(final String[] args) {
    int idx = 0;
    final String single_filename = args[idx++];
    System.out.println("single_filename = " + single_filename);
    final String keyword = args[idx++];
    System.out.println("keyword = " + keyword);
    final int seed = Integer.parseInt(args[idx++]);
    System.out.println("seed = " + seed);
    final int max_pairwise_instances = Integer.parseInt(args[idx++]);
    System.out.println("max_pairwise_instances = " + max_pairwise_instances);

    final File single_file = new File(single_filename);
    System.out.println("Opening '" + single_file.getAbsolutePath() + "'");
    assert (single_file.exists());
    final Instances single = WekaUtil.readLabeledDataset(single_file);
    final ArrayList<Attribute> single_attributes = WekaUtil.extractAttributes(single);

    final InstanceCombiner combiner;
    if ("difference".equals(keyword)) {
        combiner = new DifferenceFeatures(single_attributes);
    } else if ("symmetric".equals(keyword)) {
        combiner = new SymmetricFeatures(single_attributes);
    } else {
        throw new IllegalArgumentException("Unknown keyword '" + keyword + "'");
    }

    //      final String pair_name = FilenameUtils.getBaseName( single_filename )
    //                         + "_" + keyword + "_" + max_pairwise_instances;
    final RandomGenerator rng = new MersenneTwister(seed);
    System.out.println("Making dataset...");
    final Instances pair_instances = makePairDataset(rng, max_pairwise_instances, single, combiner);
    System.out.println("Writing dataset...");
    WekaUtil.writeDataset(single_file.getParentFile(), pair_instances);
}

From source file:com.seleniumtests.util.helper.AppTestDocumentation.java

public static void main(String[] args) throws IOException {
    File srcDir = Paths.get(args[0].replace(File.separator, "/"), "src", "test", "java").toFile();

    javadoc = new StringBuilder(
            "Cette page rfrence l'ensemble des tests et des opration disponible pour l'application\n");
    javadoc.append("\n{toc}\n\n");
    javadoc.append("${project.summary}\n");
    javadoc.append("h1. Tests\n");
    try {/*from  w  w w .j av a  2  s  .  c  o  m*/
        Path testsFolders = Files.walk(Paths.get(srcDir.getAbsolutePath())).filter(Files::isDirectory)
                .filter(p -> p.getFileName().toString().equals("tests")).collect(Collectors.toList()).get(0);

        exploreTests(testsFolders.toFile());
    } catch (IndexOutOfBoundsException e) {
        throw new ConfigurationException("no 'tests' sub-package found");
    }

    javadoc.append("----");
    javadoc.append("h1. Pages\n");
    try {
        Path pagesFolders = Files.walk(Paths.get(srcDir.getAbsolutePath())).filter(Files::isDirectory)
                .filter(p -> p.getFileName().toString().equals("webpage")).collect(Collectors.toList()).get(0);

        explorePages(pagesFolders.toFile());
    } catch (IndexOutOfBoundsException e) {
        throw new ConfigurationException("no 'webpage' sub-package found");
    }

    javadoc.append("${project.scmManager}\n");
    FileUtils.write(Paths.get(args[0], "src/site/confluence/template.confluence").toFile(), javadoc,
            Charset.forName("UTF-8"));
}

From source file:com.moss.veracity.core.Veracity.java

public static void main(String[] args) throws Exception {

    File log4jConfigFile = new File("log4j.xml");

    if (log4jConfigFile.exists()) {
        DOMConfigurator.configureAndWatch(log4jConfigFile.getAbsolutePath(), 1000);
    }//from ww w.ja v  a 2 s.  c  o m

    final Log log = LogFactory.getLog(Veracity.class);

    File homeDir = new File(System.getProperty("user.home"));
    File currentDir = new File(System.getProperty("user.dir"));

    List<File> configLocations = new LinkedList<File>();
    configLocations.addAll(Arrays.asList(new File[] { new File("/etc/veracity.config"),
            new File(homeDir, ".veracity.config"), new File(currentDir, "config.xml") }));

    String customConfigFileProperty = System.getProperty("veracity.configFile");
    if (customConfigFileProperty != null) {
        configLocations.clear();
        configLocations.add(new File(customConfigFileProperty));
    }

    File configFile = null;

    Iterator<File> i = configLocations.iterator();
    while ((configFile == null || !configFile.exists()) && i.hasNext()) {
        configFile = i.next();
    }

    LaunchParameters parameters;

    if (!configFile.exists()) {
        if (log.isDebugEnabled()) {
            log.debug("Creating default config file at " + configFile.getAbsolutePath());
        }
        parameters = new LaunchParameters();
        parameters.save(configFile);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Loading parameters from config file at " + configFile.getAbsolutePath());
        }
        parameters = LaunchParameters.load(configFile);
    }

    parameters.readSystemProperties();

    new Veracity(parameters);
}

From source file:edu.ucdenver.ccp.nlp.ae.dict_util.OboToDictionary.java

public static void main(String args[]) {

        BasicConfigurator.configure();//from w w  w . j  a v  a2 s .  com

        if (args.length < 2) {
            usage();
        } else {
            try {
                File oboFile = new File(args[0]);
                File outputFile = new File(args[1]);
                String namespaceName = "";
                if (args.length > 2) {
                    namespaceName = args[2];
                }
                if (!oboFile.canRead()) {
                    System.out.println("can't read input file;" + oboFile.getAbsolutePath());
                    usage();
                    System.exit(-2);
                }
                if (outputFile.exists() && !outputFile.canWrite()) {
                    System.out.println("can't write output file;" + outputFile.getAbsolutePath());
                    usage();
                    System.exit(-3);
                }

                logger.warn("running with: " + oboFile.getAbsolutePath());
                OboToDictionary converter = null;
                if (namespaceName != null && namespaceName.length() > 0) {
                    Set<String> namespaceSet = new TreeSet<String>();
                    namespaceSet.add(namespaceName);
                    converter = new OboToDictionary(true, SynonymType.EXACT_ONLY, namespaceSet);
                } else {
                    converter = new OboToDictionary();
                }
                converter.convert(oboFile, outputFile);
            } catch (Exception e) {
                System.out.println("error:" + e);
                e.printStackTrace();
                System.exit(-1);
            }
        }
    }

From source file:com.act.lcms.db.analysis.ConfigurableAnalysis.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());//from w  w  w. j a va2s  .  co m
    }

    CommandLine cl = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.err.format("Argument parsing failed: %s\n", e.getMessage());
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    if (cl.hasOption("help")) {
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        return;
    }

    File lcmsDir = new File(cl.getOptionValue(OPTION_DIRECTORY));
    if (!lcmsDir.isDirectory()) {
        System.err.format("File at %s is not a directory\n", lcmsDir.getAbsolutePath());
        HELP_FORMATTER.printHelp(LoadPlateCompositionIntoDB.class.getCanonicalName(), HELP_MESSAGE, opts, null,
                true);
        System.exit(1);
    }

    Double fontScale = null;
    if (cl.hasOption("font-scale")) {
        try {
            fontScale = Double.parseDouble(cl.getOptionValue("font-scale"));
        } catch (IllegalArgumentException e) {
            System.err.format("Argument for font-scale must be a floating point number.\n");
            System.exit(1);
        }
    }

    File configFile = new File(cl.getOptionValue(OPTION_CONFIG_FILE));
    if (!configFile.isFile()) {
        throw new IllegalArgumentException(
                String.format("Not a regular file at %s", configFile.getAbsolutePath()));
    }
    TSVParser parser = new TSVParser();
    parser.parse(configFile);

    try (DB db = DB.openDBFromCLI(cl)) {
        System.out.format("Loading/updating LCMS scan files into DB\n");
        ScanFile.insertOrUpdateScanFilesInDirectory(db, lcmsDir);

        List<AnalysisStep> steps = new ArrayList<>(parser.getResults().size());
        int i = 0;
        for (Map<String, String> row : parser.getResults()) {
            AnalysisStep step = mapToStep(db, i, row);
            if (step != null) {
                System.out.format("%d: %s '%s' %s %s %f %s\n", step.getIndex(), step.getKind(), step.getLabel(),
                        step.getPlateBarcode(), step.getPlateCoords(), step.getExactMass(),
                        step.getUseFineGrainedMZTolerance());
            }
            steps.add(step);
            i++;
        }

        System.out.format("Running analysis\n");
        runAnalysis(db, lcmsDir, cl.getOptionValue(OPTION_OUTPUT_PREFIX), steps,
                cl.hasOption(OPTION_USE_HEATMAP), fontScale, cl.hasOption(OPTION_USE_SNR));
    }
}