Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 19th, 2007, 7:07 AM   #1
BungalowBill
Programmer
 
Join Date: Dec 2005
Posts: 40
Rep Power: 0 BungalowBill is on a distinguished road
Writing to a text file.

Hey guys i've got a problem. Im trying to write some text to a txt file using the following code:

try{
BufferedWriter output = new BufferedWriter(new FileWriter("test.txt"));

output.write("ANYTHING");
output.write("\n");
output.write("AT");
output.write("\n");
output.write("ALL");

} catch (IOException e) {
}

No errors. The file 'test.txt' is created, but its always empty. Can anyone see what the problem is?
BungalowBill is offline   Reply With Quote
Old Mar 19th, 2007, 8:50 AM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Did you remember to close the output?
Arevos is offline   Reply With Quote
Old Mar 19th, 2007, 9:09 AM   #3
BungalowBill
Programmer
 
Join Date: Dec 2005
Posts: 40
Rep Power: 0 BungalowBill is on a distinguished road
Yeah sorry i missed that out my post by mistake. I did remember to close output.

output.close();


EDIT: so sorry, i had the close() inside of a if statement that wasn't firing. such an idiot. Thanks
BungalowBill is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
converting string to float beginnerCCC C 22 Oct 3rd, 2006 12:59 AM
OnlineTextEditor.Com! Sane Show Off Your Open Source Projects 43 Jun 16th, 2006 9:55 AM
Over writing text in a .txt file? cloud- Visual Basic 1 Apr 13th, 2005 1:43 PM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 10:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 5:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:22 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC