Java mkdir makeDirectory(final File file, final String extension)

Here you can find the source of makeDirectory(final File file, final String extension)

Description

make Directory

License

Open Source License

Declaration

public static File makeDirectory(final File file, final String extension) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static File makeDirectory(final File file, final String extension) {
        String name = file.getName();
        name = capitalizeFirstLetter(name);
        name = name.replace(".gz", "");
        name = name.replace(".zip", "");
        name = removeExtension(name);/*from   w  w w  .  j  ava 2  s  .c o  m*/
        final File dir = new File(file.getParentFile(), name + extension);
        dir.mkdir();
        return dir;
    }

    public static String capitalizeFirstLetter(final String s) {
        final char[] first = s.toCharArray();
        if (Character.isLetter(first[0])) {
            first[0] = Character.toUpperCase(first[0]);
            return new String(first);
        }
        return s;
    }

    public static String removeExtension(final String txt) {
        final int index = txt.lastIndexOf(".");
        if (index != -1) {
            return txt.substring(0, index);
        }
        return txt;
    }
}

Related

  1. makeDirectory(File file)
  2. makeDirectory(File file)
  3. makedirectory(File outputDirectory, String directoryName)
  4. makeDirectory(File testDir )
  5. makeDirectory(final CharSequence aPath)
  6. makeDirectory(String directory)
  7. makeDirectory(String directoryName)
  8. makeDirectory(String directoryPath)
  9. makeDirectory(String dirPath)