RandomAccessFile get current path

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
LVL 18
mgcITAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
objectsConnect With a Mentor 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
0
 
mgcITAuthor Commented:
i don't see the difference... how would you start the application from a directory if there is no class files?
0
 
objectsCommented:
via the classpath, class files are found via the class loader
0
 
AjarCommented:
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()


0
All Courses

From novice to tech pro — start learning today.