File name from file descriptor

Posted on 2003-10-31
Last Modified: 2008-03-06
Can I get the file name from  file descriptor using reflection.

Question by:shankii
LVL 16

Expert Comment

ID: 9659842
What do you mean by a "file descriptor" exactly?

Certainly a File object has a method (getName) which returns its name.
LVL 15

Expert Comment

ID: 9660951
Do you mean

From the javadoc:

"Applications should not create their own file descriptors."

If you mean, can you get the name of a .class file that contains the code you are examining by reflection, then get the name of the Constructor and add ".class" to it.
LVL 92

Accepted Solution

objects earned 250 total points
ID: 9661403
You can't.
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!

LVL 15

Expert Comment

ID: 9661463
Hi objects,

   I was trying not to be so blunt with my first point ;-)

Author Comment

ID: 9661477
What I meant is :

  FileInputStream fis = new FileInputStream(filename);
  fileDescriptor fd = fis.getFD();

 I want to get the file name from this fd.

LVL 92

Expert Comment

ID: 9661479
I know what you meant :)  The FileDescriptor instance knows nothing about the name of the file
LVL 15

Expert Comment

ID: 9661489
Why would you want to do that?  Why not just store filename?

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

733 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