Java Programming

BufferedCharStream

Java Programming example for write and read file using buffered character stream

10/9/2021
0 views
bufferedcharstream-file.javaJava
/* 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
Java TutorialBuffered Character Stream FileRead FileWrite File

Loading comments...

Related Examples

Deliver breaking news, insightful commentary, and exclusive reports.

Targeting readers who rely on our platform to stay ahead of the curve.

Contact Us: benzingaheadlines@gmail.com

BufferedCharStream - Java | Geekboots