Drop Down

Monday, February 4, 2019

FileWriter_1

package fileHandling;

import java.io.File;
import java.io.*;

public class FileWriter_1 {

public static void main(String[] args) throws IOException
{
  File f = new  File("D:\\work\\Java Work Space\\files\\amit.txt");
  f.createNewFile();
  System.out.println(f.exists());
 
  FileWriter fw = new FileWriter(f);  //it overrites everytime
  fw.write(97); //--->a
  fw.write('\n');
  fw.write("Book\n");
  fw.write('\n'+"on the Table");
  fw.flush();
  fw.close();
 
}

}

No comments:

Post a Comment

Java 8 Notes Pics