• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing contents of a TextArea to a File  RSS feed

 
Gerhard Abrahams
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code can be found here I just dont know how to make it happen
Started as GUI stuff
Can anyone give me some ideas?
Please.
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I take it your question is that if this code would work if commented out:

Well, it would save a serialized version of the Ausgabe object. Naming it ".txt" does not save it as a text file. You should take a gander at the Java Tutorial: IO and figure out what kind of IO suits your application, not to mention gain an understanding of Java IO before trying to implement it in your app.
 
Gerhard Abrahams
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I cant find anything that allows me to save to an ordinary text file.
Am I right in assuming that this cant be done?
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define what it is you want to save to a text file. You can write an object to a text file, but it's gonna be a bunch of nonsense since Java is writing the byte representation of the object into the text file. If you want to write data from the object, then you need to specify what sort of data you want to write out and do that.
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gerhard Abrahams:
Am I right in assuming that this cant be done?

No. You must have missed the
File Stream example which shows reading from and writing to text files. Instead of reading from one file to another, you take the text from your text area and write it out.
 
Gerhard Abrahams
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so all I need to do then is the ausgabe.getText()?
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't hurt to try. . .
 
Vrabie Cristian
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try to use DataOutputStream. This way you will be able to write that String (use DataOutputStream.writeUTF(String s) method).
Note that after this you should use the readUTF method to read the file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!