By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 819 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

File output help

P: n/a

I am having trouble writting from a JTextArea to a flat text file (locally)

I have tried using string tokenizer to tokenize the string first but with no luck,
Im stuck on the one :(

im a newbie so please take this into acount.
my snippet is below

//Post New Item from TextArea - To Vector, - then to Text File.
void postNewItem () {
try {
String Contents = singleTextArea.getText();
BufferedWriter output = new BufferedWriter( new FileWriter(urlTx) );

Enumeration eNum = testVec.elements();
while (eNum.hasMoreElements()){
String pointer = (String)eNum.nextElement();
System.out.println("writen to file "+ pointer);

}//end while
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Row wrote:
I am having trouble writting from a JTextArea to a flat text file (locally)

First, you need to define "having trouble". Do you get an exception?
If so, what is it? Do you get a compiler error? If so, what is it?

A few comments on the code:

1. The output.close() is inside your while loop. That means your file
will be opened once, but closed for each element of testVec. Probably
not what you want.

2. The formatting is such that it's difficult to understand how your
code is organized. It's conventional to indent the body of a block.
This may have confused you and contributed toward your misplacing the
close() statement.

The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.