473,395 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

File output help

Row
Hi,

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) );
testVec.addElement(Contents);

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

}//end while
Jul 17 '05 #1
1 1667
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.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
11
by: scorpion53061 | last post by:
Well I had a way to write an array to an excel spreadsheet but on a huge time critical run it failed iwth the dreaded HRESULT: 0x800A03EC error. It worked fine when i sampled the data to go in but...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
3
by: magix | last post by:
Hi, I got following to savefile into Output.txt, but how can I specify it to be in specific folder/directory (not at the same directory as the executables? Currently, it will generate the...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
3
by: RedRoses | last post by:
Hey guys i really need ur help in my C++ assignment , its very hard 4 me coz its the first time 4 me to take a course in programming or anything related to computer !!! :s so plzzzzzzzzz help me...
24
by: allpervasive | last post by:
hi all, this is reddy, a beginner to c lang,,here i have some problems in reading and modifying the contents of a file,, hope you can help to solve this problem. Here i attach the file to be...
1
by: anii | last post by:
Hi! I'm working on a piece of code for school. =) in C++. (I've read the rules and understand that i can't put all of the code here and ask for all of the code) I've got all (or most) of the code...
4
by: rsaharia | last post by:
Hello All, I need help with this particular .pl file I picked up from http://www.veritools-usa.com/xnf2vhdl.htm What it's supposed to do is really convert an xnf file to a vhdl file. I need it for...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.