Android File Create createNewFile(File file)

Here you can find the source of createNewFile(File file)

Description

create a new blank file

Parameter

Parameter Description
file a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static File createNewFile(File file) throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;

import java.io.IOException;

public class Main {
    public static File createNewFile(String filepath) throws IOException {
        return createNewFile(new File(filepath));
    }/*from ww w. j  a v a2s. co m*/

    /**
     * create a new blank file
     * @param file
     * @return
     * @throws IOException
     */
    public static File createNewFile(File file) throws IOException {
        File pareFile = file.getParentFile();
        if (pareFile.exists() || pareFile.mkdirs()) {
            File newFile = file;
            if (newFile.exists() || newFile.createNewFile())
                return newFile;
        }
        return null;
    }
}

Related

  1. createFile(String path, String content)
  2. createFile(String path, boolean isFile)
  3. createFileInFolder(File folder, String fileName)
  4. createFileInFolder(File folder, String fileName)
  5. createIfNoExist(String path)
  6. createNewFile(String filePath)
  7. createNewFile(String filePath)
  8. createNewFile(String filepath)
  9. createNewFileOnExist(String filePath)