Example code of BufferedReader and BufferedWriter class in Java. In this example code you will learn how to use these classes to perform basic read and write operations.
Java BufferedReader class is used to read the data in buffer.
The BufferedWriter class is used for buffered writing writing of data.
java.io.BufferedReader and java.io.BufferedWriter are used to read/write Strings from/to text files.
BufferedReader br; BufferedWriter bw; File f; char ca; String s; int c; // This is an int to hold either a char or -1. int offset, len, size;
|BufferedReader Constructor -- see examples|
|br =||new BufferedReader(new FileReader(f));|
|s =||br.readLine()||Returns next input line without newline char(s) or null if no more input. May throw IOException.|
|c =||br.read()||Reads and returns one char.
Returns -1 on end-of-file.
Note that that this returns an |
|size =||br.read(ca, offset, len)||Read up to len chars into ca starting at index offset. Returns -1 on end-of-file|