Java Program on How to Write Data in File
Free Java courses with 37 real-time projects - Learn Java
Program 1
package dataflair; import java.io.*; public class TestWrite1 { public static void main(String[] args) throws IOException { FileOutputStream fos=null; byte b[]; try { File F=new File("d://filedata"); F.mkdir(); fos=new FileOutputStream("d://filedata/student.txt"); char ch; String S="Data Flair free course with free certificate ,Indore MP India"; b=S.getBytes(); fos.write(b); // for(int i=0;i<b.length;i++) // System.out.print(" "+b[i]); fos.flush(); // for(int i=0;i<S.length();i++) // { // ch=S.charAt(i); // fos.write(ch); // } System.out.println("File Created......."); } finally { fos.close(); } } }
Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google