Example usage for java.io File exists

List of usage examples for java.io File exists

Introduction

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

Prototype

public boolean exists() 

Source Link

Document

Tests whether the file or directory denoted by this abstract pathname exists.

Usage

From source file:edu.ucla.cs.scai.swim.qa.ontology.dbpedia.tipicality.DbpediaCategoryAttributeCounts.java

public static void main(String args[]) throws FileNotFoundException, IOException {

    stopAttributes.add("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
    stopAttributes.add("http://www.w3.org/2002/07/owl#sameAs");
    stopAttributes.add("http://dbpedia.org/ontology/wikiPageRevisionID");
    stopAttributes.add("http://dbpedia.org/ontology/wikiPageID");
    stopAttributes.add("http://purl.org/dc/elements/1.1/description");
    stopAttributes.add("http://dbpedia.org/ontology/thumbnail");
    //stopAttributes.add("http://dbpedia.org/ontology/type");

    String path = DBpediaOntology.DBPEDIA_CSV_FOLDER;

    if (args != null && args.length > 0) {
        path = args[0];/*from  w  ww  . j a  va  2 s.  c  o  m*/
        if (!path.endsWith("/")) {
            path = path + "/";
        }
    }

    File folder = new File(path);
    if (!folder.exists()) {
        System.out.println("The path with DBpedia CSV files is set as " + path);
        System.out.println("You need to change the path with the correct one on your PC");
        System.exit(0);
    }
    for (File f : new File(path).listFiles()) {
        if (f.isFile() && f.getName().endsWith(".csv.gz")) {
            System.out.println("Processing file " + f.getName() + "...");
            processFile(f, f.getName().replaceAll("\\.csv.gz", ""));
        }
    }

    System.out.println(entities.size() + " entities processed");
    System.out.println(categories.size() + " categories found");
    System.out.println(attributes.size() + " attributes found");

    try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(path + "counts.bin"))) {
        oos.writeObject(categories);
        oos.writeObject(attributes);
        oos.writeObject(categoryCount);
        oos.writeObject(attributeCount);
        oos.writeObject(categoryAttributeCount);
        oos.writeObject(attributeCategoryCount);
    }
}

From source file:com.act.biointerpretation.l2expansion.L2RenderingDriver.java

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

    // Build command line parser.
    Options opts = new Options();
    for (Option.Builder b : OPTION_BUILDERS) {
        opts.addOption(b.build());/*w  ww .  j av  a2s.c om*/
    }

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

    // Print help.
    if (cl.hasOption(OPTION_HELP)) {
        HELP_FORMATTER.printHelp(L2RenderingDriver.class.getCanonicalName(), HELP_MESSAGE, opts, null, true);
        return;
    }

    // Set up input corpus file.
    File corpusFile = new File(cl.getOptionValue(OPTION_CORPUS_PATH));
    if (!corpusFile.exists()) {
        LOGGER.error("Input corpus file does not exist");
        return;
    }
    //Set up output directory.
    File outputDirectory = new File(cl.getOptionValue(OPTION_OUTPUT_DIRECTORY));
    if (outputDirectory.exists() && !outputDirectory.isDirectory()) {
        LOGGER.error("Can't render corpus: supplied image directory is an existing non-directory file.");
        return;
    }
    outputDirectory.mkdir();

    LOGGER.info("Reading in corpus from file.");
    L2PredictionCorpus predictionCorpus = L2PredictionCorpus.readPredictionsFromJsonFile(corpusFile);
    LOGGER.info("Finished reading in corpus with %d predictions", predictionCorpus.getCorpus().size());

    // Set image format options
    String format = cl.getOptionValue(OPTION_IMAGE_FORMAT, DEFAULT_IMAGE_FORMAT);
    Integer width = Integer.parseInt(cl.getOptionValue(OPTION_IMAGE_WIDTH, DEFAULT_IMAGE_WIDTH));
    Integer height = Integer.parseInt(cl.getOptionValue(OPTION_IMAGE_HEIGHT, DEFAULT_IMAGE_HEIGHT));

    // Render the corpus.
    LOGGER.info("Drawing images for each prediction in corpus.");
    ReactionRenderer reactionRenderer = new ReactionRenderer(format, width, height);
    PredictionCorpusRenderer renderer = new PredictionCorpusRenderer(reactionRenderer);
    renderer.renderCorpus(predictionCorpus, outputDirectory);

    LOGGER.info("L2RenderingDriver complete!");
}

From source file:com.github.megatronking.svg.cli.Main.java

public static void main(String[] args) {
    Options opt = new Options();
    opt.addOption("d", "dir", true, "the target svg directory");
    opt.addOption("f", "file", true, "the target svg file");
    opt.addOption("o", "output", true, "the output vector file or directory");
    opt.addOption("w", "width", true, "the width size of target vector image");
    opt.addOption("h", "height", true, "the height size of target vector image");

    HelpFormatter formatter = new HelpFormatter();
    CommandLineParser parser = new PosixParser();

    CommandLine cl;// w w  w  .j  a  v  a  2  s  .co m
    try {
        cl = parser.parse(opt, args);
    } catch (ParseException e) {
        formatter.printHelp(HELPER_INFO, opt);
        return;
    }

    if (cl == null) {
        formatter.printHelp(HELPER_INFO, opt);
        return;
    }

    int width = 0;
    int height = 0;
    if (cl.hasOption("w")) {
        width = SCU.parseInt(cl.getOptionValue("w"));
    }
    if (cl.hasOption("h")) {
        height = SCU.parseInt(cl.getOptionValue("h"));
    }

    String dir = null;
    String file = null;
    if (cl.hasOption("d")) {
        dir = cl.getOptionValue("d");
    } else if (cl.hasOption("f")) {
        file = cl.getOptionValue("f");
    }

    String output = null;
    if (cl.hasOption("o")) {
        output = cl.getOptionValue("o");
    }

    if (output == null) {
        if (dir != null) {
            output = dir;
        }
        if (file != null) {
            output = FileUtils.noExtensionName(file) + ".xml";
        }
    }

    if (dir == null && file == null) {
        formatter.printHelp(HELPER_INFO, opt);
        throw new RuntimeException("You must input the target svg file or directory");
    }

    if (dir != null) {
        File inputDir = new File(dir);
        if (!inputDir.exists() || !inputDir.isDirectory()) {
            throw new RuntimeException("The path [" + dir + "] is not exist or valid directory");
        }
        File outputDir = new File(output);
        if (outputDir.exists() || outputDir.mkdirs()) {
            svg2vectorForDirectory(inputDir, outputDir, width, height);
        } else {
            throw new RuntimeException("The path [" + outputDir + "] is not a valid directory");
        }
    }

    if (file != null) {
        File inputFile = new File(file);
        if (!inputFile.exists() || !inputFile.isFile()) {
            throw new RuntimeException("The path [" + file + "] is not exist or valid file");
        }
        svg2vectorForFile(inputFile, new File(output), width, height);
    }
}

From source file:au.edu.uws.eresearch.cr8it.Main.java

/**
 * Load the Spring Integration Application Context
 *
 * @param args - command line arguments/*from w  w  w.j  a  v  a2 s. c o  m*/
 */
public static void main(final String... args) {

    String contextFilePath = "spring-integration-context.xml";
    String configFilePath = "config/config-file.groovy";
    String environment = System.getProperty("environment");

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("\n========================================================="
                + "\n                                                         "
                + "\n          Welcome to C8it Integration!                 "
                + "\n                                                         "
                + "\n    For more information please visit:                   "
                + "\n    http://www.springsource.org/spring-integration       "
                + "\n                                                         "
                + "\n=========================================================");
    }

    ConfigObject config = Config.getConfig(environment, configFilePath);
    Map configMap = config.flatten();
    System.setProperty("environment", environment);
    System.setProperty("cr8it.client.config.file", (String) configMap.get("file.runtimePath"));

    //final AbstractApplicationContext context =
    //new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/*-context.xml");

    String absContextPath = "config/integration/" + contextFilePath;
    File contextFile = new File(absContextPath);
    final AbstractApplicationContext context;
    if (!contextFile.exists()) {
        absContextPath = "classpath:" + absContextPath;
        context = new ClassPathXmlApplicationContext(absContextPath);
    } else {
        absContextPath = "file:" + absContextPath;
        context = new FileSystemXmlApplicationContext(absContextPath);
    }

    context.registerShutdownHook();

    SpringIntegrationUtils.displayDirectories(context);

    final Scanner scanner = new Scanner(System.in);

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("\n========================================================="
                + "\n                                                         "
                + "\n    Please press 'q + Enter' to quit the application.    "
                + "\n                                                         "
                + "\n=========================================================");
    }

    while (!scanner.hasNext("q")) {
        //Do nothing unless user presses 'q' to quit.
    }

    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("Exiting application...bye.");
    }

    System.exit(0);

}

From source file:com.foxykeep.parcelablecodegenerator.Main.java

public static void main(String[] args) {

    File fileInputDir = new File("input");
    if (!fileInputDir.exists() || !fileInputDir.isDirectory()) {
        return;// w  w w.  j av  a 2  s.  com
    }

    ArrayList<FileInfo> fileInfoList = new ArrayList<FileInfo>();
    findJsonFiles(fileInputDir, null, fileInfoList);

    StringBuilder sb = new StringBuilder();

    // For each file in the input folder
    for (FileInfo fileInfo : fileInfoList) {
        String fileName = fileInfo.file.getName();
        System.out.println("Generating code for " + fileName);

        char[] buffer = new char[2048];
        sb.setLength(0);
        Reader in;
        try {
            in = new InputStreamReader(new FileInputStream(fileInfo.file), "UTF-8");
            int read;
            do {
                read = in.read(buffer, 0, buffer.length);
                if (read != -1) {
                    sb.append(buffer, 0, read);
                }
            } while (read >= 0);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return;
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }

        String content = sb.toString();
        if (content.length() == 0) {
            System.out.println("file is empty.");
            return;
        }

        try {
            JSONObject root = new JSONObject(content);

            // Classes generation
            String classPackage, className, superClassPackage, superClassName;
            boolean isSuperClassParcelable, hasSubClasses, isAbstract;

            classPackage = root.getString("package");
            className = root.getString("name");
            superClassPackage = JsonUtils.getStringFixFalseNull(root, "superClassPackage");
            superClassName = JsonUtils.getStringFixFalseNull(root, "superClassName");
            isSuperClassParcelable = root.optBoolean("isSuperClassParcelable");
            hasSubClasses = root.optBoolean("hasSubClasses");
            if (hasSubClasses) {
                isAbstract = root.optBoolean("isAbstract");
            } else {
                isAbstract = false;
            }

            JSONArray fieldJsonArray = root.optJSONArray("fields");
            ArrayList<FieldData> fieldDataList;
            if (fieldJsonArray != null) {
                fieldDataList = FieldData.getFieldsData(fieldJsonArray);
            } else {
                fieldDataList = new ArrayList<FieldData>();
            }

            // Parcelable generation
            ParcelableGenerator.generate(fileInfo.dirPath, classPackage, className, superClassPackage,
                    superClassName, isSuperClassParcelable, hasSubClasses, isAbstract, fieldDataList);
        } catch (JSONException e) {
            e.printStackTrace();
            return;
        }
    }

}

From source file:de.zazaz.iot.bosch.indego.util.IndegoIftttAdapter.java

public static void main(String[] args) {
    System.setProperty("log4j.configurationFile", "log4j2-indegoIftttAdapter-normal.xml");

    Options options = new Options();

    StringBuilder commandList = new StringBuilder();
    for (DeviceCommand cmd : DeviceCommand.values()) {
        if (commandList.length() > 0) {
            commandList.append(", ");
        }//from ww  w .j a v a2  s .  c  o  m
        commandList.append(cmd.toString());
    }

    options.addOption(Option //
            .builder("c") //
            .longOpt("config") //
            .desc("The configuration file to use") //
            .required() //
            .hasArg() //
            .build());
    options.addOption(Option //
            .builder("d") //
            .longOpt("debug") //
            .desc("Logs more details") //
            .build());
    options.addOption(Option //
            .builder("?") //
            .longOpt("help") //
            .desc("Prints this help") //
            .build());

    CommandLineParser parser = new DefaultParser();
    CommandLine cmds = null;
    try {
        cmds = parser.parse(options, args);
    } catch (ParseException ex) {
        System.err.println(ex.getMessage());
        System.err.println();
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(IndegoIftttAdapter.class.getName(), options);
        System.exit(1);
        return;
    }

    if (cmds.hasOption("?")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(CmdLineTool.class.getName(), options);
        return;
    }

    if (cmds.hasOption("d")) {
        System.setProperty("log4j.configurationFile", "log4j2-indegoIftttAdapter-debug.xml");
    }

    String configFileName = cmds.getOptionValue('c');
    File configFile = new File(configFileName);

    if (!configFile.exists()) {
        System.err.println(String.format("The specified config file (%s) does not exist", configFileName));
        System.err.println();
        System.exit(2);
        return;
    }

    Properties properties = new Properties();
    try (InputStream in = new FileInputStream(configFile)) {
        properties.load(in);
    } catch (IOException ex) {
        System.err.println(ex.getMessage());
        System.err.println(String.format("Was not able to load the properties file (%s)", configFileName));
        System.err.println();
    }

    IftttIndegoAdapterConfiguration config = new IftttIndegoAdapterConfiguration();
    config.setIftttMakerKey(properties.getProperty("indego.ifttt.maker.key"));
    config.setIftttIgnoreServerCertificate(
            Integer.parseInt(properties.getProperty("indego.ifttt.maker.ignore-server-certificate")) != 0);
    config.setIftttReceiverPort(Integer.parseInt(properties.getProperty("indego.ifttt.maker.receiver-port")));
    config.setIftttReceiverSecret(properties.getProperty("indego.ifttt.maker.receiver-secret"));
    config.setIftttOfflineEventName(properties.getProperty("indego.ifttt.maker.eventname-offline"));
    config.setIftttOnlineEventName(properties.getProperty("indego.ifttt.maker.eventname-online"));
    config.setIftttErrorEventName(properties.getProperty("indego.ifttt.maker.eventname-error"));
    config.setIftttErrorClearedEventName(properties.getProperty("indego.ifttt.maker.eventname-error-cleared"));
    config.setIftttStateChangeEventName(properties.getProperty("indego.ifttt.maker.eventname-state-change"));
    config.setIndegoBaseUrl(properties.getProperty("indego.ifttt.device.base-url"));
    config.setIndegoUsername(properties.getProperty("indego.ifttt.device.username"));
    config.setIndegoPassword(properties.getProperty("indego.ifttt.device.password"));
    config.setPollingIntervalMs(Integer.parseInt(properties.getProperty("indego.ifttt.polling-interval-ms")));

    IftttIndegoAdapter adapter = new IftttIndegoAdapter(config);
    adapter.startup();
}

From source file:io.apiman.tools.jdbc.ApimanJdbcServer.java

public static void main(String[] args) {
    try {/*from  w  ww  .j a v a  2s . c  o m*/
        File dataDir = new File("target/h2");
        String url = "jdbc:h2:tcp://localhost:9092/apiman";

        if (dataDir.exists()) {
            FileUtils.deleteDirectory(dataDir);
        }
        dataDir.mkdirs();

        Server.createTcpServer("-tcpPassword", "sa", "-baseDir", dataDir.getAbsolutePath(), "-tcpPort", "9092",
                "-tcpAllowOthers").start();
        Class.forName("org.h2.Driver");

        try (Connection connection = DriverManager.getConnection(url, "sa", "")) {
            System.out.println("Connection Established: " + connection.getMetaData().getDatabaseProductName()
                    + "/" + connection.getCatalog());
            executeUpdate(connection,
                    "CREATE TABLE users ( username varchar(255) NOT NULL, password varchar(255) NOT NULL, PRIMARY KEY (username))");
            executeUpdate(connection,
                    "INSERT INTO users (username, password) VALUES ('bwayne', 'ae2efd698aefdf366736a4eda1bc5241f9fbfec7')");
            executeUpdate(connection,
                    "INSERT INTO users (username, password) VALUES ('ckent', 'ea59f7ca52a2087c99374caba0ff29be1b2dcdbf')");
            executeUpdate(connection,
                    "INSERT INTO users (username, password) VALUES ('ballen', 'ea59f7ca52a2087c99374caba0ff29be1b2dcdbf')");
            executeUpdate(connection,
                    "CREATE TABLE roles (rolename varchar(255) NOT NULL, username varchar(255) NOT NULL)");
            executeUpdate(connection, "INSERT INTO roles (rolename, username) VALUES ('user', 'bwayne')");
            executeUpdate(connection, "INSERT INTO roles (rolename, username) VALUES ('admin', 'bwayne')");
            executeUpdate(connection, "INSERT INTO roles (rolename, username) VALUES ('ckent', 'user')");
            executeUpdate(connection, "INSERT INTO roles (rolename, username) VALUES ('ballen', 'user')");
        }

        System.out.println("======================================================");
        System.out.println("JDBC (H2) server started successfully.");
        System.out.println("");
        System.out.println("  Data: " + dataDir.getAbsolutePath());
        System.out.println("  JDBC URL: " + url);
        System.out.println("  JDBC User: sa");
        System.out.println("  JDBC Password: ");
        System.out.println(
                "  Authentication Query:   SELECT * FROM users u WHERE u.username = ? AND u.password = ?");
        System.out.println("  Authorization Query:    SELECT r.rolename FROM roles r WHERE r.username = ?");
        System.out.println("======================================================");
        System.out.println("");
        System.out.println("");
        System.out.println("Press Enter to stop the JDBC server.");
        new BufferedReader(new InputStreamReader(System.in)).readLine();

        System.out.println("Shutting down the JDBC server...");

        Server.shutdownTcpServer("tcp://localhost:9092", "", true, true);

        System.out.println("Done!");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step7aLearningDataProducer.java

@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException {
    String inputDir = args[0];/* w  w w.  ja va  2  s . co m*/
    File outputDir = new File(args[1]);

    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    Collection<File> files = IOHelper.listXmlFiles(new File(inputDir));

    // for generating ConvArgStrict use this
    String prefix = "no-eq_DescendingScoreArgumentPairListSorter";

    // for oversampling using graph transitivity properties use this
    //        String prefix = "generated_no-eq_AscendingScoreArgumentPairListSorter";

    Iterator<File> iterator = files.iterator();
    while (iterator.hasNext()) {
        File file = iterator.next();

        if (!file.getName().startsWith(prefix)) {
            iterator.remove();
        }
    }

    int totalGoldPairsCounter = 0;

    Map<String, Integer> goldDataDistribution = new HashMap<>();

    DescriptiveStatistics statsPerTopic = new DescriptiveStatistics();

    int totalPairsWithReasonSameAsGold = 0;

    DescriptiveStatistics ds = new DescriptiveStatistics();

    for (File file : files) {
        List<AnnotatedArgumentPair> argumentPairs = (List<AnnotatedArgumentPair>) XStreamTools.getXStream()
                .fromXML(file);

        int pairsPerTopicCounter = 0;

        String name = file.getName().replaceAll(prefix, "").replaceAll("\\.xml", "");

        PrintWriter pw = new PrintWriter(new File(outputDir, name + ".csv"), "utf-8");

        pw.println("#id\tlabel\ta1\ta2");

        for (AnnotatedArgumentPair argumentPair : argumentPairs) {
            String goldLabel = argumentPair.getGoldLabel();

            if (!goldDataDistribution.containsKey(goldLabel)) {
                goldDataDistribution.put(goldLabel, 0);
            }

            goldDataDistribution.put(goldLabel, goldDataDistribution.get(goldLabel) + 1);

            pw.printf(Locale.ENGLISH, "%s\t%s\t%s\t%s%n", argumentPair.getId(), goldLabel,
                    multipleParagraphsToSingleLine(argumentPair.getArg1().getText()),
                    multipleParagraphsToSingleLine(argumentPair.getArg2().getText()));

            pairsPerTopicCounter++;

            int sameInOnePair = 0;

            // get gold reason statistics
            for (AnnotatedArgumentPair.MTurkAssignment assignment : argumentPair.mTurkAssignments) {
                String label = assignment.getValue();

                if (goldLabel.equals(label)) {
                    sameInOnePair++;
                }
            }

            ds.addValue(sameInOnePair);
            totalPairsWithReasonSameAsGold += sameInOnePair;
        }

        totalGoldPairsCounter += pairsPerTopicCounter;
        statsPerTopic.addValue(pairsPerTopicCounter);

        pw.close();
    }

    System.out.println("Total reasons matching gold " + totalPairsWithReasonSameAsGold);
    System.out.println(ds);

    System.out.println("Total gold pairs: " + totalGoldPairsCounter);
    System.out.println(statsPerTopic);

    int totalPairs = 0;
    for (Integer pairs : goldDataDistribution.values()) {
        totalPairs += pairs;
    }
    System.out.println("Total pairs: " + totalPairs);
    System.out.println(goldDataDistribution);

}

From source file:com.twentyn.patentScorer.PatentScorer.java

public static void main(String[] args) throws Exception {
    System.out.println("Starting up...");
    System.out.flush();// w  ww. j  av  a  2 s.c  om
    Options opts = new Options();
    opts.addOption(Option.builder("i").longOpt("input").hasArg().required()
            .desc("Input file or directory to score").build());
    opts.addOption(Option.builder("o").longOpt("output").hasArg().required()
            .desc("Output file to which to write score JSON").build());
    opts.addOption(Option.builder("h").longOpt("help").desc("Print this help message and exit").build());
    opts.addOption(Option.builder("v").longOpt("verbose").desc("Print verbose log output").build());

    HelpFormatter helpFormatter = new HelpFormatter();
    CommandLineParser cmdLineParser = new DefaultParser();
    CommandLine cmdLine = null;
    try {
        cmdLine = cmdLineParser.parse(opts, args);
    } catch (ParseException e) {
        System.out.println("Caught exception when parsing command line: " + e.getMessage());
        helpFormatter.printHelp("DocumentIndexer", opts);
        System.exit(1);
    }

    if (cmdLine.hasOption("help")) {
        helpFormatter.printHelp("DocumentIndexer", opts);
        System.exit(0);
    }

    if (cmdLine.hasOption("verbose")) {
        // With help from http://stackoverflow.com/questions/23434252/programmatically-change-log-level-in-log4j2
        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
        Configuration ctxConfig = ctx.getConfiguration();
        LoggerConfig logConfig = ctxConfig.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
        logConfig.setLevel(Level.DEBUG);

        ctx.updateLoggers();
        LOGGER.debug("Verbose logging enabled");
    }

    String inputFileOrDir = cmdLine.getOptionValue("input");
    File splitFileOrDir = new File(inputFileOrDir);
    if (!(splitFileOrDir.exists())) {
        LOGGER.error("Unable to find directory at " + inputFileOrDir);
        System.exit(1);
    }

    try (FileWriter writer = new FileWriter(cmdLine.getOptionValue("output"))) {
        PatentScorer scorer = new PatentScorer(PatentModel.getModel(), writer);
        PatentCorpusReader corpusReader = new PatentCorpusReader(scorer, splitFileOrDir);
        corpusReader.readPatentCorpus();
    }
}

From source file:com.axiomine.largecollections.generator.GeneratorPrimitiveList.java

public static void main(String[] args) throws Exception {
    //Package of the new class you are generating Ex. com.mypackage
    String MY_PACKAGE = args[0];/*from w  w w  . j a va2s  .  c  om*/
    //Any custom imports you need (: seperated). Use - if no custom imports are included
    //Ex. java.util.*:java.lang.Random     
    String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1];
    //Package of your Key serializer class. Use com.axiomine.bigcollections.functions
    String T = args[2];

    String tCls = T;

    if (tCls.equals("byte[]")) {
        tCls = "BytesArray";
    }
    String CLASS_NAME = tCls + "List";
    File root = new File("");
    File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/"
            + CLASS_NAME + ".java");

    if (outFile.exists()) {
        System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again");
    }
    {
        String[] imports = null;
        String importStr = "";

        if (!StringUtils.isBlank(CUSTOM_IMPORTS)) {
            CUSTOM_IMPORTS.split(":");
            for (String s : imports) {
                importStr = "import " + s + ";\n";
            }
        }

        String program = FileUtils.readFileToString(
                new File(root.getAbsolutePath() + "/src/main/resources/PrimitiveListTemplate.java"));

        program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE);
        program = program.replaceAll("#CUSTOM_IMPORTS#", importStr);

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#T#", T);
        program = program.replaceAll("#TCLS#", tCls);

        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}