Android Utililty Methods File Create

List of utility methods to do File Create

Description

The list of methods to do File Create are organized into topic(s).

Method

voidcreateChecksum(String path)
Stores the checksum of a given directory tree in a file at the root of that directory.
long checksum_long = computeChecksum(path);
byte[] checksum = String.valueOf(checksum_long).getBytes();
File f = new File(getDir(path), CHECKSUM_FILENAME);
FileOutputStream os = new FileOutputStream(f);
os.write(checksum); 
os.close();
voidcreateFile(File file, boolean isFile)
create File
if (!file.exists()) {
    if (!file.getParentFile().exists()) {
        createFile(file.getParentFile(), false);
    } else {
        if (isFile) {
            try {
                file.createNewFile();
            } catch (IOException e) {
...
voidcreateFile(String file, String content, String encodType)
create File
FileOutputStream writerStream = new FileOutputStream(file);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
        writerStream, encodType));
writer.write(content);
writer.close();
writerStream.close();
voidcreateFile(String fileName)
create File
File file = new File(fileName);
if (!file.exists()) {
    if (!file.createNewFile())
        throw new IOException("Create file fail!");
FileOutputStreamcreateFile(String fileName)
Create a FileOutputStream corresponding to a particular file name.
if (fileName == null) {
    throw new IllegalArgumentException("null file");
File f = new File(fileName);
if (f.getParentFile() != null && !f.getParentFile().exists()) {
    boolean result = f.getParentFile().mkdirs();
    if (!result) {
        throw new IOException("failed to create "
...
voidcreateFile(String filePathAndName, String fileContent)
create File
try {
    String filePath = filePathAndName;
    filePath = filePath.toString();
    File myFilePath = new File(filePath);
    if (!myFilePath.exists()) {
        myFilePath.createNewFile();
} catch (Exception e) {
...
FilecreateFile(String path)
Procedure for creating a File
File file = new File(path);
if (!file.exists()) {
    try {
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
return file;
booleancreateFile(String path)
create File
File file = new File(path);
try {
    if (file.exists()) {
        if (file.delete()) {
            file.createNewFile();
    } else {
        file.createNewFile();
...
voidcreateFile(String path, List content)
create File
File arq = null;
arq = new File(path);
write(arq, content);
booleancreateFile(String path, String content)
create File
try {
    File arch = null;
    arch = new File(path);
    BufferedWriter wtr = new BufferedWriter(new FileWriter(arch));
    wtr.write(content);
    wtr.flush();
    wtr.close();
    arch.setWritable(true);
...