Monday, November 14, 2016

Write file in java | simple file write in java



package com.jignesh;

import java.io.File;

public class WriteFileExample
{
    public static void main(String[] args)
    {
     try{

      File file = new File("c:\\jigneshExample.txt");

          if (!file.exists()) {
                file.createNewFile();
            }

            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write("hello how are you!");
            bw.close();


     }catch(Exception e){

      e.printStackTrace();

     }

    }
}

3 comments:

  1. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.
    best web design services | professional web development company

    ReplyDelete
  2. That's great information. Thanks for sharing this blog. I did a search and found your blog and glowing review. It's been a big help! Thanx for sharing. 
    Laravel Development Services | Angularjs Development Services

    ReplyDelete