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

voidwrite(File file, List content)
write
try {
    BufferedWriter wtr = new BufferedWriter(new FileWriter(file));
    for (String c : content) {
        wtr.write(c);
    wtr.flush();
    wtr.close();
} catch (FileNotFoundException e) {
...
voidwrite(File file, String content)
write
try {
    BufferedWriter wtr = new BufferedWriter(new FileWriter(file));
    wtr.write(content);
    wtr.flush();
    wtr.close();
} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
...
voidwrite(File file, String s)
write
if (file.getParent() != null) {
    mkdirs(file.getParent());
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
bw.flush();
bw.write(s);
bw.flush();
bw.close();
...
voidwrite(File file, String s, boolean lazy)
write
write(file, s, lazy, false);
voidwrite(File file, String s, boolean lazy, boolean append)
write
if (file.getParent() != null) {
    mkdirs(file.getParent());
if (lazy && file.exists()) {
    String content = read(file);
    if (content.equals(s)) {
        return;
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
        new FileOutputStream(file, append), StringPool.UTF8));
bw.write(s);
bw.close();
voidwrite(String fileName, String s)
write
write(new File(fileName), s);
voidwrite(String pathName, String fileName, String s)
write
write(new File(pathName, fileName), s);
voidwrite2File(Set set, String path)
write File
File file = new File(path);
try {
    file.createNewFile();
    BufferedWriter bw = new BufferedWriter(new FileWriter(file));
    for (String str : set) {
        bw.write(str);
        bw.newLine();
    bw.flush();
    bw.close();
} catch (IOException e) {
    e.printStackTrace();
voidwriteFile(File f, String content)
write string s into file f
final FileWriter fw = new FileWriter(f);
fw.append(content);
fw.close();
voidwriteFile(File file, String content)
Reads some bytes from the file.
if (!file.exists()) {
    file.getParentFile().mkdirs();
FileWriter out = null;
try {
    out = new FileWriter(file);
    out.write(content);
} finally {
...