Solved

RandomAccessFile get current path

Posted on 2006-10-19
4
981 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

636 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