Results 1 to 9 of 9
Thread: Saving contents of textarea
- 07-06-2011, 07:47 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
Saving contents of textarea
Hi. I am new here.
I have written a programme that calculates figures in textfields then displays them in a textarea. I was wondering if there is anyway to save the figures and text in the textarea. I know it would come under the ioexception and printerscanner. I was just wondering if there is an easy way to do it as the data is in the textarea, rather than having to write every entry that was previously in the textboxes into the ioexception.
Is there any examples of code any of you could provide or any suggestions to do this easily.
Thank you.
- 07-06-2011, 07:53 PM #2
JTextArea (Java Platform SE 6)Java Code:myTextArea.getText();
-> JTextComponent (Java Platform SE 6)
--> JTextComponent.getText() (Java Platform SE 6)
Reading the Api's are often helpful. It you look JTextArea inherits methods from JTextComponent, JTextComponent has a getText() method which returns a String containing the information in the JTextComponent. In this case, your JTextArea.- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 07-06-2011, 08:08 PM #3
This is a strange task.write every entry that was previously in the textboxes into the ioexception
What is a "ioexception"? How do write into it?
- 07-06-2011, 08:19 PM #4
I think he meant IO to a file, or something similar.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 07-06-2011, 08:52 PM #5
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
Yep that is what I meant. I have already used the get.text function to get the figures from the individual textfields then displayed in the textarea. I want to save the conglomerated figures to the harddrive in a file format then reopen them again. I was wondering whether there is an easy way to this by getting the text from the textarea rather than the individual textfields. Then saving it to a file I can reopen.
- 07-06-2011, 08:56 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 07-06-2011, 08:57 PM #7
Yes there is, are you familiar with java.io (Java Platform SE 6) ?
Try taking a look at BufferedWriter (Java Platform SE 6)
I did something similar by using a BufferedWriter connected to a FileWriter and simply usedHowever I'm still fairly new to this, and JosAH's suggestion may work better. I would have to look into the proper syntax of his method to help you further.Java Code:myBufferedWriter.write(myTextArea.getText());
Last edited by Dark; 07-06-2011 at 09:00 PM.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 07-06-2011, 08:58 PM #8
First take a look at how the file output methods work. For a text file, you will be writing the output line by line.
A line being a String followed by the newline character.
- 07-06-2011, 09:04 PM #9
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Saving the contents of a variable to disk
By ckannan90 in forum New To JavaReplies: 2Last Post: 08-11-2010, 10:37 PM -
How to get(copy) the contents i.e the contents in the cells of an excel sheet
By johnvarg in forum AWT / SwingReplies: 1Last Post: 02-23-2010, 09:48 AM -
Problems saving a file and printing its contents.
By gth05 in forum New To JavaReplies: 3Last Post: 12-03-2009, 10:05 PM -
how to display the contents of textfile in textarea at runtime using JSP
By shrvasu in forum Advanced JavaReplies: 1Last Post: 10-29-2008, 07:01 PM -
TextArea Bug?
By Soda in forum New To JavaReplies: 2Last Post: 12-07-2007, 12:37 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks