Example usage for java.io File mkdir

List of usage examples for java.io File mkdir

Introduction

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

Prototype

public boolean mkdir() 

Source Link

Document

Creates the directory named by this abstract pathname.

Usage

From source file:br.edu.ifpb.sislivros.model.RequisicaoDeImg.java

public static void inserirImagem(FileItem item, String realPath, String nomeDaImagem) throws IOException {

    //Pegar o diretorio /imagensPerfil dentro do diretorio atual
    String diretorio = realPath + "/";

    //Criar diretorio caso no exista;
    File f = new File(diretorio);

    if (!f.exists()) {
        f.mkdir();
    }//from  w  w  w .j  a  v  a2  s.c o m

    //Mandar o arquivo para o diretorio informado
    f = new File(diretorio + nomeDaImagem + ".jpg");

    try {
        FileOutputStream output = new FileOutputStream(f);
        InputStream is = item.getInputStream();

        byte[] buffer = new byte[2048];

        int nLidos;

        while ((nLidos = is.read(buffer)) >= 0) {
            output.write(buffer, 0, nLidos);
        }

        output.flush();
    } finally {

    }

}

From source file:Main.java

@SuppressWarnings("ResultOfMethodCallIgnored")
public static File getAvatarsCacheDir(Context context) {
    File cacheDir = new File(context.getCacheDir(), AVATARS_CACHE_FOLDER);
    if (!cacheDir.exists()) {
        cacheDir.mkdir();
    }//w  w  w . j  a v a 2  s  . c om
    return cacheDir;
}

From source file:Main.java

public static File getSavePath() {
    File path;
    if (hasSDCard()) { // SD card
        path = new File(getSDCardPath() + "/flipbook/");
        path.mkdir();
    } else {// w w w.ja v a2s  .  co m
        path = Environment.getDataDirectory();
    }
    return path;
}

From source file:com.netflix.imfutility.ImfUtilityTest.java

@BeforeClass
public static void setupAll() throws IOException {
    // create both working directory and logs folder.
    FileUtils.deleteDirectory(TemplateParameterContextCreator.getWorkingDir());
    File workingDir = TemplateParameterContextCreator.getWorkingDir();
    if (!workingDir.mkdir()) {
        throw new RuntimeException("Could not create a working dir within tmp folder");
    }/*from  w  w w .  jav a2  s  .  c  om*/

    File logs = new File(TemplateParameterContextCreator.getWorkingDir(), CoreConstants.LOGS_DIR);
    if (!logs.mkdir()) {
        throw new RuntimeException("Could not create a log dir within working dir");
    }
}

From source file:Main.java

public static String writeBitmap(byte[] data) throws IOException {
    File file = new File(Environment.getExternalStorageDirectory() + "/bookclip/");
    file.mkdir();
    String bitmapPath = file.getPath() + "/" + System.currentTimeMillis() + ".jpg";
    FileOutputStream outStream = new FileOutputStream(bitmapPath);
    outStream.write(data);//from  www. j av a 2s. co m
    outStream.close();

    return bitmapPath;
}

From source file:Main.java

public static void createDirectory(String folderName) {
    File folder = new File(folderName);
    if (!folder.exists() || !folder.isDirectory()) {
        folder.mkdir();
    }/*from   w w w .ja  va2 s.  c o m*/
}

From source file:Main.java

public static void makeRootDirectory(String filePath) {
    File file = null;
    try {//w  w w  . j  a  v a 2  s. c o m
        file = new File(filePath);
        if (!file.exists()) {
            file.mkdir();
        }
    } catch (Exception e) {

    }
}

From source file:com.netflix.spinnaker.clouddriver.appengine.artifacts.StorageUtils.java

public static void untarStreamToPath(InputStream inputStream, String basePath) throws IOException {
    class DirectoryTimestamp {
        public DirectoryTimestamp(File d, long m) {
            directory = d;// w w w .  j  a v a 2 s.c om
            millis = m;
        }

        public File directory;
        public long millis;
    }
    ;
    // Directories come in hierarchical order within the stream, but
    // we need to set their timestamps after their children have been written.
    Stack<DirectoryTimestamp> directoryStack = new Stack<DirectoryTimestamp>();

    File baseDirectory = new File(basePath);
    baseDirectory.mkdir();

    TarArchiveInputStream tarStream = new TarArchiveInputStream(inputStream);
    for (TarArchiveEntry entry = tarStream.getNextTarEntry(); entry != null; entry = tarStream
            .getNextTarEntry()) {
        File target = new File(baseDirectory, entry.getName());
        if (entry.isDirectory()) {
            directoryStack.push(new DirectoryTimestamp(target, entry.getModTime().getTime()));
            continue;
        }
        writeStreamToFile(tarStream, target);
        target.setLastModified(entry.getModTime().getTime());
    }

    while (!directoryStack.empty()) {
        DirectoryTimestamp info = directoryStack.pop();
        info.directory.setLastModified(info.millis);
    }
    tarStream.close();
}

From source file:melnorme.utilbox.tests.TestsWorkingDir.java

public static void initWorkingDir(String workingDir) {
    assertTrue(workingDir != null);/* www.  j a  v a  2  s.  c o m*/
    assertTrue(testsWorkingDir == null);
    testsWorkingDir = workingDir;

    System.out.println("====>> WORKING DIR: " + testsWorkingDir);

    File file = new File(testsWorkingDir);
    if (!file.exists()) {
        file.mkdir();
    }
}

From source file:io.github.bluemarlin.util.BluemarlineUtil.java

public static File loadOrCreateDirectory(File file) {
    if (!file.exists()) {
        file.mkdir();
    }//  w  w  w . ja v  a  2 s  . c o m
    return file;
}