0

I am making a small application, like a travel agency app, and I was wondering how you could send inputted information (from a JOptionPane.showInputDialog ("")) type of input. I need it to be sent to a file, where I can later retrieve it, like a database. Any ideas?

Code:

public boolean action (Event e, Object o)
{
    String firstName = JOptionPane.showInputDialog ("Please Enter your first name: ");
    String lastName = JOptionPane.showInputDialog ("Please Enter your last name: ");
    String address = JOptionPane.showInputDialog ("Please Enter your address: ");
    String telephone = JOptionPane.showInputDialog ("Please Enter your telephone num: ");
    return true;
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Andrew
  • 535
  • 3
  • 10
  • 25
  • 1
    Plenty, but may be you could start with [Basic I/O](http://docs.oracle.com/javase/tutorial/essential/io/) and [JDBC basics](http://docs.oracle.com/javase/tutorial/jdbc/basics/) and try something – MadProgrammer Jan 20 '14 at 02:36
  • @MadProgrammer do you know if BufferedReader would work in this situation? – Andrew Jan 20 '14 at 02:38
  • That depends on how the data is written and how you want to interact with it, but it is certainly possible – MadProgrammer Jan 20 '14 at 02:43
  • Please **stop** adding the [tag:console] to your questions, and please ***read*** the tag pop-ups before adding them to a post. This is so far the 3rd of your posts from which I have removed this irrelevant tag! – Andrew Thompson Jan 20 '14 at 02:46

2 Answers2

2

Given this is an applet, you might want to look into cookies and the HTML5 webstorage. Either can be used from a sand-boxed applet.

Note that to use a local DB or a File would require a fully signed and trusted applet.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    As an aside, I think you are being a little to quick to accept answers.. There is a lot of 'less than optimal' advice offered when it comes to applets. :-/ – Andrew Thompson Jan 20 '14 at 02:52
1

See this previous SO question. Basically, you just print your strings into an output.

How do I create a file and write to it in Java?

Community
  • 1
  • 1
mjkaufer
  • 4,047
  • 5
  • 27
  • 55
  • 1
    Or you could store in XML or JSON or a single user/stand alone database or through a database server... – MadProgrammer Jan 20 '14 at 02:44
  • Thanks, I knew the answer was out there somewhere, I guess I wasn't specific enough in my Google search ;-) – Andrew Jan 20 '14 at 02:48