Java Utililty Methods File Append

List of utility methods to do File Append

Description

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

Method

voidappendContent(File file, String content, String encoding)
Append text content to file, with encoding.
Writer writer = null;
try {
    writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true), encoding));
    writer.append(content);
} finally {
    if (writer != null) {
        writer.flush();
        writer.close();
...
voidappendContentsToFile(File file, StringBuilder contents)
Used to add contents to a file
PrintStream ps = null;
try {
    FileOutputStream os = new FileOutputStream(file);
    ps = new PrintStream(os);
    ps.print(contents.toString());
} finally {
    ps.close();
voidappendContentsTofile(String fileName, String contents)
append Contents Tofile
RandomAccessFile file = null;
try {
    file = new RandomAccessFile(fileName, "rw");
    file.seek(file.length());
    file.writeBytes(contents);
} finally {
    if (file != null)
        file.close();
...
voidappendContentToFile(File file, String fileContent)
Append file contents into specified file
BufferedWriter out = new BufferedWriter(new FileWriter(file, true));
out.write(fileContent);
out.close();
voidappendFile(byte[] data, String file)
Appends data to the file
writeStream(data, new FileOutputStream(file, true));
voidappendFile(File f, String content)
append File
BufferedWriter writer = null;
try {
    writer = new BufferedWriter(new FileWriter(f, true));
    writer.write(content);
} catch (Exception e) {
    throw e;
} finally {
    if (writer != null) {
...
voidappendFile(File f, StringBuffer sb)
append File
try {
    BufferedReader br = new BufferedReader(new FileReader(f));
    char[] buffer = new char[1000];
    int c = 0;
    while ((c = br.read(buffer)) > 0) {
        sb.append(buffer, 0, c);
} catch (IOException e) {
...
voidappendFile(File file, String content)
Write some text into the end of a file (append)
BufferedWriter bw = null;
try {
    bw = new BufferedWriter(new FileWriter(file, true));
    bw.write(content);
    bw.flush();
} catch (FileNotFoundException e) {
    if (bw != null)
        bw.close();
...
voidappendFile(File file, String url)
append File
FileWriter fw;
try {
    fw = new FileWriter(file, true); 
    fw.write(url);
    fw.close();
} catch (IOException e) {
    e.printStackTrace();
voidappendFile(File filename, String data)
append File
try (BufferedWriter out = new BufferedWriter(new FileWriter(filename, true))) {
    out.write(data);