1.FileWriter writer = new FileWriter (filename,true);
True indicates that the base of the original text is appended.
2.
BufferedWriter
The efficiency of writing becomes a problem when the content of the file is written. You can use BufferedWriter to cushion it.
Both the BufferedWriter and FileWriter classes are used to output character streams, which contain almost identical methods, but BufferedWriter provides a newline () method for line wrapping. This line break is cross-platform.
public class Bufferedwritertester {
public static void Main (string[] args) throws ioexception{
TODO auto-generated Method Stub
String filename = "NewHello.txt";
BufferedWriter out = new BufferedWriter (new FileWriter (filename));
Out.write ("Hello");
Out.newline ();
Out.write ("I can start from another line");
Out.close ();
}
}
3. Reading characters from a text file
FileReader class:
-read characters from a text file
-Inherits from the subclass of the reader abstract class InputStreamReader
BufferedReader
-Buffer class for reading text files
-With the ReadLine () method, you can identify the line character and read the contents of the input stream in one line.
-Inherit from reader.
Java Read File Learning