• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving/Opening a text file, from a text area.

 
Jayson Johnson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am new to this site. I have posted a few times in devshed, I have also asked a similar question as I am now. Thanks to several over at devshed I have got a calculator program working and added a few things to it. My question is that, I added a textarea, and I want to be able to open simple text files, and save to a text file. I have done some googling and looked around at java.sun, but im still not sure which methods/classes I need to accomplish this. I have already coded the menus for save/open, but I dont know how to actually search for and OPEN a text or SAVE AS a text. If anyone can point me in the right direction it would be greatly appreciated. BTW, MyDevShedPost this is the post at devshed, complete with the code for my calculator. Thanks in advance.

-Jay
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34396
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayson,
Forgetting about your Swing interface for a minute, do you know how to write a program with a main method to read a file and output to the result to standard out? If so, you are most of the way there.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
Jayson Johnson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, not at all. Although I have been playing around with it and got it to open a text file, BUT it only displayed the first line, AND you had to type in the filename. BUT this is far from what I want to do, as I couldnt navigate through the file system and it only opened 1 line. I have since found that I need to be looking at FileReader and FileWriter. Basically what I need to do is understand what it actually does to save and open a file. What I mean does it just copy it straight in? Or does it have to convert it? Any information will help. As I find the java.sun is informative, but not user friendly. Its still somewhat Greek to me. Thanks.

-Jay
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you need to use a JFileChooser to chose a file. It also sounds like you should read the Basic I/O tutorial to learn more about those things.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic