package FilesInputOutput;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import javax.swing.JOptionPane;

public class CreateFile {
public static void main(String[] args) {
         try{
                 FileWriter fileObj = new FileWriter("Testing.txt");
                  BufferedWriter buffer = new BufferedWriter(fileObj);
                  PrintWriter outputObj = new PrintWriter(buffer);
                  
                  //                  outputObj.println("COLEGIO COLOMBO BRITÁNICO");
                //                  outputObj.println("Computer Science");
                //                  outputObj.println("12/02/2015");
                //                  outputObj.println("I. D. 16.855.766");
                //                  outputObj.println(true);
                  
                  String name=JOptionPane.showInputDialog("Your name");
                  String lastName=JOptionPane.showInputDialog("Your last name");
                  int age=Integer.parseInt(JOptionPane.showInputDialog("Your age"));           
                  String report=name+"\r\n"+lastName+"\r\n"+age;
                  System.out.println(report);
                  outputObj.println(report);
                  outputObj.close();
                  buffer.close();
                  
          }catch (FileNotFoundException evt){
	JOptionPane.showMessageDialog(null, "File not created");
          }catch(IOException evt){
	JOptionPane.showMessageDialog(null, "Writing failed");
          }    
}
}
