In this tutorial, you will learn how to Write Char by Char into a File in java. To understand it better, you may want to check the following first:
Java Program to Write Char by Char into a File
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | //write char by char into a file in java import java.io.*; public class FileByChar { public static void main(String[] args) throws IOException { File f=new File("javaCode.txt"); //Creation of File Descriptor for output file FileWriter fw=new FileWriter(f); //Creation of File Writer object fw.write('S'); //Write character by Character fw.write('i'); fw.write('m'); fw.write('p'); fw.write('l'); fw.write('e'); fw.write('2'); fw.write('C'); fw.write('o'); fw.write('d'); fw.write('e'); fw.flush(); fw.close(); System.out.println("Check the javaCode.txt file"); } } |
Output:
Check the javaCode.txt file
Open javaCode.txt file that will be created after execution of a program
javaCode.txt
Simple2Code