Android File Create createFile(String filePathAndName, String fileContent)

Here you can find the source of createFile(String filePathAndName, String fileContent)

Description

create File

Declaration

public void createFile(String filePathAndName, String fileContent) 

Method Source Code

//package com.java2s;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.OutputStreamWriter;

public class Main {
    private String message;

    public void createFile(String filePathAndName, String fileContent) {

        try {//from w w  w .  j a v  a 2 s  .c  o  m
            String filePath = filePathAndName;
            filePath = filePath.toString();
            File myFilePath = new File(filePath);
            if (!myFilePath.exists()) {
                myFilePath.createNewFile();
            }
        } catch (Exception e) {
            message = "";
            e.printStackTrace();
        }
    }

    public static void createFile(String file, String content,
            String encodType) throws IOException {
        FileOutputStream writerStream = new FileOutputStream(file);
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
                writerStream, encodType));
        writer.write(content);
        writer.close();
        writerStream.close();
    }
}

Related

  1. createChecksum(String path)
  2. createFile(File file, boolean isFile)
  3. createFile(String file, String content, String encodType)
  4. createFile(String fileName)
  5. createFile(String fileName)
  6. createFile(String path)
  7. createFile(String path)
  8. createFile(String path, List content)
  9. createFile(String path, String content)