BufferedCharStream

Java Programming

Java Programming Examples

/* Buffered character stream */
import java.io.*;

class bufferedcharfile {
	public static void main(String args[ ]) throws IOException {

		/* Declare and create input file */
		FileWriter wf = new FileWriter("bufferdfile.txt");
		BufferedWriter wb = new BufferedWriter(wf);
		wb.write("Bufferd Character Stream file!");
		System.out.println("File created!");
		wb.close();
		wf.close();

		/* Read till end of the file */
		FileReader rf = new FileReader("bufferdfile.txt");
		BufferedReader rb = new BufferedReader(rf);
		System.out.println("Reading File -");
		int data = 0;
		while ((data = rb.read()) != -1)
			System.out.print((char) data);
		System.out.println();
		rb.close();
		rf.close();
	}
}


          /****** Output ******/
          

File Created!




Reading File -


Bufferd Stream File

Learn more about FileWriter, FileReader, BufferedWriter and BufferedReader