Android Utililty Methods Text File Write

List of utility methods to do Text File Write

Description

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

Method

voidwriteSet2File(Set set, String filePath)
write Set File
if (set == null || filePath == null || set.isEmpty()) {
    return;
File file = new File(filePath);
if (!file.exists()) {
    if (log.isInfoEnabled()) {
        log.info("create file:" + file.getPath());
    file.createNewFile();
BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
for (String str : set) {
    bw.write(str);
    bw.newLine();
bw.close();
voidwriteString(String string, File file, boolean append)
Simply executes #writeBytes writeBytes ( string.getBytes(), file, append ).
Check.arg().notNull(string);
writeBytes(string.getBytes(), file, append);
voidwriteStringToFile(String content, String fileName)
Writes a string to a file.
BufferedWriter fw = createBufferedUtf8Writer(fileName);
fw.write(content);
fw.flush();
fw.close();
voidwriteStringToFile(String content, String fileName, boolean append)
Writes a string to a file.
BufferedWriter fw = createBufferedUtf8Writer(fileName, append);
fw.write(content);
fw.flush();
fw.close();
voidwriteStringToFile(String string, File file)
write String To File
FileWriter fw = new FileWriter(file);
fw.append(string);
fw.close();
voidwriteStringToFile(String stringToWrite, String filename)
write String To File
OutputStream os = new FileOutputStream(filename);
os.write(stringToWrite.getBytes());
os.close();
voidwriteText(File file, String text)
write Text
writeText(file, text, null);
voidwriteText(File file, String text, String charsetName)
write Text
byte[] bytes = charsetName == null ? text.getBytes() : text
        .getBytes(charsetName);
writeBytes(file, false, bytes);
voidwriteTextFile(String path, String text)
Writes the contents of a String to a file.
FileWriter writer = new FileWriter(path, false);
writer.write(text);
writer.close();
FilewriteTextFile(String string, String fileName)
write text to a specified text file store in temporary path
try {
    File file = new File(FileUtil.tmpdir + fileName + ".txt");
    FileOutputStream fos = new FileOutputStream(file);
    OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
    osw.write(string);
    osw.flush();
    osw.close();
    fos.close();
...