Example usage for java.io File isDirectory

List of usage examples for java.io File isDirectory

Introduction

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

Prototype

public boolean isDirectory() 

Source Link

Document

Tests whether the file denoted by this abstract pathname is a directory.

Usage

From source file:com.bcmcgroup.flare.client.PublisherOutbox11.java

public static void main(String[] args) {

    if (args.length != 1) {
        usage();/*from   w ww . j a v a 2 s.co m*/
    }

    if (args[0].equals("-h") || args[0].equals("--help") || args[0].equals("?") || args[0].equals("help")) {
        usage();
    }

    File file = new File(args[0]);

    if (file.isDirectory() && file.exists()) {
        new PublisherOutbox11(file);
    }

}

From source file:com.temenos.interaction.rimdsl.generator.launcher.Main.java

public static void main(String[] args) {
    // handle command line options
    final Options options = new Options();
    OptionBuilder.withArgName("src");
    OptionBuilder.withDescription("Model source");
    OptionBuilder.hasArg();/*from  ww  w  . ja v  a 2 s .  co  m*/
    OptionBuilder.isRequired();
    OptionBuilder.withValueSeparator(' ');
    Option optSrc = OptionBuilder.create("src");

    OptionBuilder.withArgName("targetdir");
    OptionBuilder.withDescription("Generator target directory");
    OptionBuilder.hasArg();
    OptionBuilder.isRequired();
    OptionBuilder.withValueSeparator(' ');
    Option optTargetDir = OptionBuilder.create("targetdir");

    options.addOption(optSrc);
    options.addOption(optTargetDir);

    // create the command line parser
    final CommandLineParser parser = new GnuParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, args);
    } catch (final ParseException exp) {
        System.err.println("Parsing arguments failed.  Reason: " + exp);
        wrongCall(options);
        return;
    }

    // execute the generator
    Injector injector = new RIMDslStandaloneSetup().createInjectorAndDoEMFRegistration();
    Generator generator = injector.getInstance(Generator.class);
    File srcFile = new File(line.getOptionValue(optSrc.getArgName()));
    if (srcFile.exists()) {
        boolean result = false;
        if (srcFile.isDirectory()) {
            result = generator.runGeneratorDir(srcFile.getPath(),
                    line.getOptionValue(optTargetDir.getArgName()));
        } else {
            result = generator.runGenerator(srcFile.getPath(), line.getOptionValue(optTargetDir.getArgName()));
        }
        System.out.println("Code generation finished [" + result + "]");
    } else {
        System.out.println("Src dir not found.");
    }

}

From source file:com.temenos.interaction.rimdsl.generator.launcher.MainSpringPRD.java

public static void main(String[] args) {
    // handle command line options
    final Options options = new Options();
    OptionBuilder.withArgName("src");
    OptionBuilder.withDescription("Model source");
    OptionBuilder.hasArg();//from  w w w. j a v  a  2 s  . com
    OptionBuilder.isRequired();
    OptionBuilder.withValueSeparator(' ');
    Option optSrc = OptionBuilder.create("src");

    OptionBuilder.withArgName("targetdir");
    OptionBuilder.withDescription("Generator target directory");
    OptionBuilder.hasArg();
    OptionBuilder.isRequired();
    OptionBuilder.withValueSeparator(' ');
    Option optTargetDir = OptionBuilder.create("targetdir");

    options.addOption(optSrc);
    options.addOption(optTargetDir);

    // create the command line parser
    final CommandLineParser parser = new GnuParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, args);
    } catch (final ParseException exp) {
        System.err.println("Parsing arguments failed.  Reason: " + exp);
        wrongCall(options);
        return;
    }

    // execute the generator
    Injector injector = new RIMDslStandaloneSetupSpringPRD().createInjectorAndDoEMFRegistration();
    Generator generator = injector.getInstance(Generator.class);
    File srcFile = new File(line.getOptionValue(optSrc.getArgName()));
    if (srcFile.exists()) {
        boolean result = false;
        if (srcFile.isDirectory()) {
            result = generator.runGeneratorDir(srcFile.getPath(),
                    line.getOptionValue(optTargetDir.getArgName()));
        } else {
            result = generator.runGenerator(srcFile.getPath(), line.getOptionValue(optTargetDir.getArgName()));
        }
        System.out.println("Code generation finished [" + result + "]");
    } else {
        System.out.println("Src dir not found.");
    }

}

From source file:com.bcmcgroup.flare.client.PublisherOutbox10.java

public static void main(String[] args) {

    if (args.length != 1) {
        usage();/*w w  w  . j  av a2 s .c  om*/
    }

    if (args[0].equals("-h") || args[0].equals("--help") || args[0].equals("?") || args[0].equals("help")) {
        usage();
    }

    File file = new File(args[0]);

    if (file.isDirectory() && file.exists()) {
        new PublisherOutbox10(file);
    }

}

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;/* ww  w  . j  av  a 2s  .  c om*/
    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:com.siemens.scr.avt.ad.io.AnnotationBatchLoader.java

public static void main(String[] args) {
    initLogging();/*  ww w  . j ava  2s . co  m*/
    assert args.length > 0 : "A directory should be provided!";

    String path = args[0];
    logger.debug("Loading from directory " + path);

    File directory = new File(path);

    assert directory != null : "Directory should exist!";
    assert directory.isDirectory() : "The path " + path + " should point to a directory!";

    List<String> argStrings = new ArrayList<String>();
    for (int i = 0; i < args.length; i++) {
        argStrings.add(args[i]);
    }

    AnnotationBatchLoader loader = new AnnotationBatchLoader();
    try {
        loader.parseSegDicomFromDirectroy(directory);
        loader.loadFromDirectory(directory);
    } catch (Exception e) {
        logger.error("Error while loading:");
        e.printStackTrace();
    }
    logger.info("done");
}

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;/*from  w w w  .  j  a v  a  2 s.c  o m*/
    }

    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:jeplus.util.LineEnds.java

public static void main(String[] args) {

    String LN = "\r\n";

    // create the parser
    CommandLineParser parser = new GnuParser();
    Options options = getCommandLineOptions();
    CommandLine commandline = null;/* w  w w  .j  a  va2 s . com*/
    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(80);
    try {
        // parse the command line arguments
        commandline = parser.parse(options, args);
        if (commandline.hasOption("help")) {
            // automatically generate the help statement
            formatter.printHelp("java -cp jEPlusNet.jar jeplusplus.util.LineEnds [OPTIONS]", options);
            System.exit(-1);
        }
        // Set log4j configuration
        if (commandline.hasOption("log")) {
            PropertyConfigurator.configure(commandline.getOptionValue("log"));
        } else {
            PropertyConfigurator.configure("log4j.cfg");
        }
    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
        // automatically generate the help statement
        formatter.printHelp("java -Xmx500m -jar JESS_Client.jar [OPTIONS]", options);
        System.exit(-1);
    }

    if (commandline.hasOption("style")) {
        if (commandline.getOptionValue("style").startsWith("L")) {
            LN = "\n";
        }
    }

    if (commandline.hasOption("file")) {
        File file = new File(commandline.getOptionValue("file"));
        if (file.exists()) {
            if (file.isDirectory()) {
                File[] listOfFiles = file.listFiles();
                for (int i = 0; i < listOfFiles.length; i++) {
                    if (listOfFiles[i].isFile()) {
                        convertFile(listOfFiles[i], LN);
                    }
                }
            } else {
                convertFile(file, LN);
            }
        }
    }
}

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());//from  w ww.j a va 2s  .  c  o m
    }

    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:fr.jamgotchian.tuplegen.core.Main.java

public static void main(String[] args) {
    CommandLineParser parser = new PosixParser();

    try {/*from  w  w  w .j  a  va  2s  .c  o  m*/
        CommandLine line = parser.parse(OPTIONS, args);
        if (line.hasOption("h") || !line.hasOption("c") || !line.hasOption("d")) {
            usage();
        }
        File genSrcDir = new File(line.getOptionValue("d"));
        if (!genSrcDir.exists()) {
            throw new IllegalArgumentException(genSrcDir + " does not exit");
        }
        if (!genSrcDir.isDirectory()) {
            throw new IllegalArgumentException(genSrcDir + " should be a directory");
        }
        File cfgFile = new File(line.getOptionValue("c"));
        if (!cfgFile.exists()) {
            throw new IllegalArgumentException(cfgFile + " does not exist");
        }
        TupleGen generator = new TupleGen();
        generator.generate(cfgFile, genSrcDir, false, LOGGER);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}