Solved

RandomAccessFile get current path

Posted on 2006-10-19
4
867 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
Comment Utility
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
Comment Utility
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
Comment Utility
via the classpath, class files are found via the class loader
0
 
LVL 6

Expert Comment

by:Ajar
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now