View Single Post
  #14 (permalink)  
Old 01-02-2008, 11:35 AM
simi's Avatar
simi simi is offline
Member
 
Join Date: Dec 2007
Location: Singapore
Posts: 18
simi is on a distinguished road
Send a message via Yahoo to simi
Hi,

import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.FileWriter;
import javax.swing.*;
public class Test
{

public static void main(String[] args)
{
String name = JOptionPane.showInputDialog("Please Enter Your name");

JOptionPane.showMessageDialog(null,"Welcome " + name);
String password = JOptionPane.showInputDialog("Please Enter Your Password");



try
{
BufferedWriter bufferedwriter = new BufferedWriter(
new FileWriter("C:\\Test\\file.txt"));

PrintWriter out = new PrintWriter(bufferedwriter);
out.println(name);
out.println(password);
out.close();

}
catch(IOException e)
{
System.out.println("Error processing file: " + e);
}


}
}


updated Gibson's code. The above code will create file.txt in c:\test directory. before running this code , dont forget to create test directory.

This reservation project is a good start to learn java. i've learned java 8 years back by doing these kind of projects instead of reading more theory. i would like to suggest you to start it and when you encounter error post it here. we will try our best to help.

All the best.

Simi

Regards,
Simi
Reply With Quote