Sunday, April 29, 2018

Write the data in a file using FileWriter class !!

Using FileWriter: 
  1. import java.io.File;
  2. import java.io.FileWriter;
  3. import java.io.IOException;

  4. public class WriteByFileWriter {

  5. public static void main(String[] args) throws IOException {
  6. File file = new File("D:\\data1.txt");
  7. FileWriter contacts = new FileWriter(file);
  8. contacts.write("suresh - 9999999999\n");
  9. contacts.write("ritesh - 0000000000\n");
  10. contacts.write("mahesh - 8888888888");
  11. contacts.close();
  12. }
  13. }
Output:
suresh - 9999999999
ritesh - 0000000000
mahesh - 8888888888

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...