Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RandomAccessFile get current path

Posted on 2006-10-19
4
Medium Priority
?
1,016 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

722 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