Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

need help with writing user input to file  RSS feed

 
Kiran Kaur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am trying to take user input (customer info such as name, address, phone number , etc. from many text fields - I use enter to go to next text field as they are set up in a grid layout). This is done in one class and when you click the "Save" button in the frame I want to write this information to a random access file. Do I do this in the same class or do I need to create a new class for this and, if so, how do I keep track of the user input from the frame in this new class? I also do not want to allow duplicate names to be entered. I know about DataInputStream and FileInputStream and System.in but am confused as to how I go about starting all of this and putting it all together?? Any help would be greatly appreciated as I am fairly new to Java!
 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first try to learn about IO streams in more detail

 
Kiran Kaur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I somewhat understand IO streams but there are so many options. I want to be able to append to the file that I am reading from and writing this data to so it's more a matter of syntax and what would be the better option - to use DataOutputStream, FileOutputStream or ObjectOutputStream.
Originally posted by maateen ashraf:
first try to learn about IO streams in more detail

 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use FileoutputStream
and then create a PrintStream object with FileoutputStream object as parameter of its constructor and then use
println() method of PrintStream class
hope it helps
r u happy now?

Originally posted by Kiran Kaur:
I somewhat understand IO streams but there are so many options. I want to be able to append to the file that I am reading from and writing this data to so it's more a matter of syntax and what would be the better option - to use DataOutputStream, FileOutputStream or ObjectOutputStream.


[This message has been edited by Gaurav Chikara (edited March 22, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!