Solved

RandomAccessFile get current path

Posted on 2006-10-19
4
928 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:mgcIT
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 17770495
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
 
LVL 18

Author Comment

by:mgcIT
ID: 17770696
i don't see the difference... how would you start the application from a directory if there is no class files?
0
 
LVL 92

Expert Comment

by:objects
ID: 17770718
via the classpath, class files are found via the class loader
0
 
LVL 6

Expert Comment

by:Ajar
ID: 17771324
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question