File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Where to Create an Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Where to Create an "output" Directory" Watch "Where to Create an "output" Directory" New topic
Author

Where to Create an "output" Directory

Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 320
I am fixing a bug in a Java class that is given by another developer. The problem happens in this line of code:



The error message is:

.\output\gov.nih.nci.cabio.domain._test.xml (The system cannot find the path specified)


Question 1: should I create a directory called "output"?
Question 2: where should I create this "output" directory?
Question 3: should I also create an empty file with a name "gov.nih.nci.cabio.domain._test.xml"?

Thanks very much for guidance.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16487
    
    2

1. Yes, you should create an "output" directory.

2. If you want to use that code, you should create it under the current working directory which was and will be in effect when that code is run.

3. No, you don't need to create an empty file before writing. The FileWriter or FileOutputStream will take care of that.

And for the question you didn't ask yet:

4. What happens if I can't control the current working directory which will be in effect when that code is run?

In that case you should choose a fixed location for the "output" directory and write your code so that it refers to that fixed location. Use an absolute path instead of a relative path.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Moving thread as too difficult for "beginning"
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Where to Create an "output" Directory
 
Similar Threads
EJB project
JBOSS is not working
zipCreation utility
problrm in creation of file and dircectory
java read file problem