RandomAccessFile get current path

mgcIT
mgcIT used Ask the Experts™
on
can I create a RandomAccessFile and use the path that the current app (.class file) is running in?

for example :

RAF = new RandomAccessFile("Menu.txt", "r");


where Menu.txt is in the same folder as the class files that the app is currently running from.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Java Developer
Top Expert 2010
Commented:
you can do that but the current disrectory is not necessarily the same folder as the class.
The current directory will be the one the application was started from

Author

Commented:
i don't see the difference... how would you start the application from a directory if there is no class files?
Mick BarryJava Developer
Top Expert 2010

Commented:
via the classpath, class files are found via the class loader

Commented:
Use following code to get hold of the location of the current class file
assuming MYClass is the class name


this.class.getResource("MYClass.class").toString()


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial