![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Dec 2005
Posts: 40
Rep Power: 0
![]() |
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? |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Did you remember to close the output?
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Dec 2005
Posts: 40
Rep Power: 0
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |