This is what I have. I'm wondering if there's a better solution. The text_ variable is a JTextArea member of the class.
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
posted
0
Try getText(). When you look at the API for a class, be sure to also check for inherited methods from base classes.
"I'm not back." - Bill Harding, Twister
Brian C Robinson
Greenhorn
Joined: Feb 21, 2002
Posts: 7
posted
0
I don't see how getText() will help. I guess I should have been clearer about the help I wanted. I don't like the character by character read in the load() method. What is an alternative to that.
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
posted
0
Oops - I didn't read carefully enough. You can user the read(char[]) and write(char[]) to handle a large number of characters at once. You'll need to create your own char[] array as a buffer, transferring chars from one stream to another. That's generally the preferred way to make IO more efficient. It will still need to be in a loop, as you can never guarantee how many chars will be read each time - but you can do a lot more reading/writing in each iteration. Also, you may find it useful to presize your StringBuffer using the length() method of the File class. This also depends on the character encoding used. It speeds things up if the StringBuffer doesn't have to keep resizing itself.