Tuesday, 7 March 2017

Write into file in append mode / file writer

package com.google.email;

import java.io.*;
import java.io.IOException;

public class WriteTextUtil {
public void writeInAppendMode(String path, String strFinal) throws IOException {
BufferedWriter bw = null;
FileWriter fw = null;
try {
fw = new FileWriter(path, true);
bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter(bw);
out.println(strFinal);
out.println("\n");

} finally {
if (bw != null)
bw.close();

if (fw != null)
fw.close();
}
}
}