• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where to Create an "output" Directory  RSS feed

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving thread as too difficult for "beginning"
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!