Example usage for java.io File mkdirs

List of usage examples for java.io File mkdirs

Introduction

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

Prototype

public boolean mkdirs() 

Source Link

Document

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

Usage

From source file:Main.java

public static void main(String[] a) {
    File file = new File("c:\\test\\test\\");
    file.mkdirs();
}

From source file:Main.java

public static void main(String[] args) {
    String directories = "D:\\a\\b\\c\\d\\e\\f\\g\\h\\i";
    File file = new File(directories);

    boolean result = file.mkdirs();
    System.out.println("Status = " + result);
}

From source file:Main.java

public static void main(String[] args) {
    File dir = new File("C:/1/Parent1/Parent2/DemoDir");
    boolean isDirCreated = dir.mkdirs();
    if (isDirCreated)
        System.out.println("created");
    else//from w w w  . java 2  s  .  c  o m
        System.out.println("Failed");

}

From source file:Main.java

public static void main(String[] args) {

    // returns pathnames for files and directory
    File f = new File("C:/Texts/a/b/c");

    // create directories
    boolean bool = f.mkdirs();

    System.out.print("Directory created? " + bool);

}

From source file:GuaranteeAFile.java

public static void main(String[] args) {

    String filename = "C:/myFile.txt";
    File aFile = new File(filename);
    if (aFile.isDirectory()) {
        System.out.println("The path " + aFile.getPath() + " does not specify a file. Program aborted.");
        System.exit(1);//from   w w w.j  a  v  a 2  s. c o m
    }
    if (!aFile.isFile()) {
        aFile = aFile.getAbsoluteFile();
        File parentDir = new File(aFile.getParent());
        if (!parentDir.exists()) {
            parentDir.mkdirs();
        }
    }
    FileOutputStream outputFile = null;
    try {
        outputFile = new FileOutputStream(aFile, true);
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
}

From source file:fr.dutra.tools.maven.deptree.extras.VelocityRendererMain.java

/**
 * Arguments list:/*from ww  w .ja  v a2  s . c  om*/
 * <ol>
 * <li>Full path of dependency tree file to parse;</li>
 * <li>Dependency tree file format; must be the (case-insensitive) name of a <code>{@link InputType}</code> enum;</li>
 * <li>Full path to the output directory where HTML files and static resources will be generated (<em>this directory will be erased</em>);</li>
 * <li>Renderer format; must be the (case-insensitive) name of a <code>{@link VelocityRenderType}</code> enum;</li>
 * </ol>
 * @param args
 * @throws ParseException
 * @throws IOException
 * @throws VisitException
 */
public static void main(String[] args) throws IOException, ParseException, VisitException {
    InputType format = InputType.valueOf(args[1].toUpperCase());
    Parser parser = format.newParser();
    Node tree = parser.parse(new FileReader(args[0]));
    File outputDir = new File(args[2]);
    FileUtils.deleteDirectory(outputDir);
    outputDir.mkdirs();
    VelocityRenderer renderer = VelocityRenderType.valueOf(args[3].toUpperCase()).newRenderer();
    renderer.setFileName("index.html");
    renderer.setOutputDir(outputDir);
    renderer.visit(tree);
}

From source file:dk.qabi.imapfs.IMAPMount.java

public static void main(String[] args) throws MessagingException, MalformedURLException {

    if (args.length < 2) {
        System.out.println("[Error]: Must specify a mounting point");
        System.out.println();//from  w w  w  .  j a  v a  2  s.  c om
        System.out.println("[Usage]: imapfsmnt <mounting point>");
        System.exit(-1);
    }

    final String urlSpec = args[0];
    final URL url = new URL(null, urlSpec, new IMAPStreamHandler());
    final String mountpoint = args[1];

    String[] fs_args = new String[4];
    fs_args[0] = "-f";
    fs_args[1] = "-s";
    fs_args[2] = mountpoint;
    fs_args[3] = "-ovolname=" + url.getHost() + ",fssubtype=7";

    Filesystem imapfs = new LoggingFilesystem(new IMAPFileSystem(url), LogFactory.getLog("dk.qabi.imapfs"));

    File m = new File(mountpoint);
    if (!m.exists())
        m.mkdirs();

    try {
        FuseMount.mount(fs_args, imapfs);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:br.com.RatosDePC.Brpp.BrppCompilerMain.java

public static void main(String[] args) {
    // TODO Auto-generated method stub
    File f = new File(FileUtils.getBrinodirectory());
    f.mkdirs();
    File l = new File(FileUtils.getBrinodirectory() + "/bibliotecas");
    l.mkdirs();//from  ww w  .jav  a 2  s.c  om
    Path currentRelativePath = Paths.get("");
    String s = currentRelativePath.toAbsolutePath().toString();
    File destDir = new File(s + System.getProperty("file.separator") + "Arduino"
            + System.getProperty("file.separator") + "libraries");
    try {
        JSONUtils.config(s);
    } catch (IOException | ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        FileUtils.copyFolder(l, destDir);
        KeywordManagerUtils.processLibraries();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    BrppIDEFrame frame = new BrppIDEFrame("Brino " + BrppCompiler.version);
    frame.setSize(500, 600);
    frame.setVisible(true);
    frame.setLocation(100, 30);

}

From source file:com.sazneo.export.formatter.Main.java

public static void main(String... args) {

    Log logger = LogFactory.getLog(Main.class);

    if (args.length != 3) {
        logger.error("Usage: java Main <stylesheet> <export xml file> <output dir>");
        System.exit(1);/*from  ww w. ja  v  a  2 s  .co  m*/
    }

    String styleSheetPath = args[0];
    File styleSheet = new File(styleSheetPath);

    String exportXmlPath = args[1];
    File exportXml = new File(exportXmlPath);

    String outPutDirPath = args[2];
    File outputDir = new File(outPutDirPath);
    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    try {
        File outputFile = new File(outputDir, "export.html");
        FileOutputStream outputStream = new FileOutputStream(outputFile);
        HtmlFormatter formatter = new HtmlFormatter(styleSheet, exportXml, outputStream);
        formatter.transform();
        FileProcessor fileProcessor = new FileProcessor(exportXml, outputDir);
        fileProcessor.process();

    } catch (IOException e) {
        logger.error(MessageFormat.format("Failed to create export.html at {0}:\n {1}", outPutDirPath, e));
    }
}

From source file:Main.java

public static void main(String[] args) {

    File directory = new File("C:/temp/temp1/temp2/temp3");
    if (directory.mkdir()) {
        System.out.println("Success mkdir");
    } else {// ww w  . j  a  v a  2 s.  c  o m
        if (directory.mkdirs()) {
            System.out.println("Success mkdirs");
        } else {
            System.out.println("Failed");
        }
    }
}