This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello everyone, I'm having trouble writing data to a text file. The code I have right now compiles and even gives me System.out.println messages that suggest it is working, but it doesn't seem to be actually creating the text file (or at least I can't find it). Any help with this would be awesome. Thanks in advance!
What's with putting quotes in the filename? In Windows I'm not allowed to create files with quotes in their names. You're probably using Windows too, and even if you aren't, that probably isn't a valid filename.
Probably best to print rather more details from the catch; a stack trace might give useful information.
Joined: Oct 16, 2008
I'm actually on a mac, but I was just trying the quotes out to see if it made a difference (it didn't). My catch block is not catching anything, either (when I run, it prints the "working" from within the try block).
Thank you everyone for the replies. It apparently is creating the text file correctly now (it works when I call my load file method), but I still can't find where it is saving to.... hmm... oh well! At least it works, if mysteriously. Thanks again!
Change the first line of the try block to This will print out the filename you supply and the absolute path of your file that Java uses. These may or may not be the same. If they are different and you don't understand why, come back and someone should be able to explain.