aspose file tools*
The moose likes Beginning Java and the fly likes Reading files within packages... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reading files within packages..." Watch "Reading files within packages..." New topic
Author

Reading files within packages...

Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
Now that I have my application successfully broken out into packages, I have run into a small problem.
Before, when I had all my classes in the same directory and no packages, I also had in this directory a .properties file. Only on eclass needs access to this file, so when I created my packages I moved this file to the same package directory as the object that needs it.
When I try to run my application, I get an error saying that the file could not be found. What is the trick to proper file placement? I do not want to hard-code the address...
TIA


Wait a minute, I'm trying to think of something clever to say...<p>Joel
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Have you tried placing the file in the root directory of your package structure? I'm not sure if that will do the trick.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
Thanks for the idea Dirk, it made me try what actually worked...
I had to move it to the directory just above my package root (unless that is what you meant...)
Example:
java GUI class installed in C:\CAMRA2
my package structure is C:\CAMRA2\com\massappraisal\myPackages
I had to put the file in C:\CAMRA2, but it worked.
Thanks again,
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
That is what I meant, and I'm glad it works, because it makes sense that it could.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading files within packages...