Character File

/* Character stream */

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

		/* Declare and create input file */
		FileWriter fwrite = new FileWriter("charfile.txt");
		fwrite.write("This is a character file!");
		System.out.println("File Created!\n");

		/* Read till end of the file */
		FileReader freader = new FileReader("charfile.txt");
		int rf;
		System.out.println("Reading File -");
		while((rf = != -1)
			System.out.print((char) rf);

/* Output */
File Created!

Reading File -
This is a character file!

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!