Java Utililty Methods File Append Text

List of utility methods to do File Append Text

Description

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

Method

voidappendTextToFile(String text, File file)
append Text To File
try (FileOutputStream fileOutputStream = new FileOutputStream(file, true)) {
    fileOutputStream.write(text.getBytes());
} catch (IOException e) {
    throw new RuntimeException("Error while appending text to file", e);
voidappendToFile(File destFile, InputStream source)
append To File
try {
    int chars_read = 0;
    BufferedReader in = new BufferedReader(new InputStreamReader(source, "GBK"));
    List datas = new ArrayList();
    while (in.ready()) {
        char[] data = new char[1024];
        chars_read += in.read(data, 0, 1024);
        datas.add(data);
...
voidappendToFile(File file, String data)
append To File
FileWriter fw = new FileWriter(file, true);
fw.write(data);
fw.close();
voidappendToFile(File tempFile, String str)
append To File
BufferedOutputStream fout = null;
try {
    fout = new BufferedOutputStream(new FileOutputStream(tempFile, true));
    fout.write(str.getBytes());
} finally {
    if (fout != null)
        fout.close();
voidappendToFile(final File file, final String contents)
Appends the contents String to a file.
try (FileOutputStream fos = new FileOutputStream(file, true)) {
    fos.write(contents.getBytes());
booleanappendToFile(final String filePath, final String textToAppend)
append To File
try (FileWriter fw = new FileWriter(filePath, true)) {
    fw.write(textToAppend);
    fw.close();
    return true;
} catch (final Exception e) {
    return false;
voidappendToFile(final String text, final String urlFile)
Append the specified text at the end of the File.
final FileWriter fw = new FileWriter(urlFile, true);
final BufferedWriter output = new BufferedWriter(fw);
try {
    output.write(text);
    output.newLine();
    output.flush();
} finally {
    output.close();
...
voidappendToFile(float[] in, String filename)
append To File
BufferedWriter outputWriter = null;
outputWriter = new BufferedWriter(new FileWriter(filename));
for (int i = 0; i < in.length; i++) {
    outputWriter.write(Float.toString(in[i]));
    outputWriter.newLine();
outputWriter.flush();
outputWriter.close();
...
booleanappendToFile(IFile file, String output)
append To File
try {
    if (!file.exists())
        return false;
    InputStream source = new ByteArrayInputStream(output.getBytes());
    file.appendContents(source, IFile.FORCE, null);
    return true;
} catch (CoreException e) {
    e.printStackTrace();
...
voidappendToFile(List strList, File file)
append To File
if ((strList == null) || (strList.isEmpty()) || (file == null)) {
    return;
BufferedWriter bw = null;
try {
    bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
    for (String str : strList) {
        bw.write(str);
...