here code for make new file ..
how i can make it to insert data to file and open it
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package files;
import java.io.*;
import java.util.Scanner;
public class Files{
public static void main(String[] args)
throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter the file name to create : ");
String file_name = in.readLine();
File file = new File(file_name);
boolean exist = file.createNewFile();
if (!exist)
{
System.out.println("File already exists.");
System.exit(0);
}
else
{
FileWriter fstream = new FileWriter(file_name);
BufferedWriter out = new BufferedWriter(fstream);
out.write(in.readLine());
//4out.close();
System.out.println("File created successfully.");
}
}
}