File name from file descriptor

Can I get the file name from  file descriptor using reflection.

Thanks
shankiiAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
You can't.
0
 
imladrisCommented:
What do you mean by a "file descriptor" exactly?

Certainly a File object has a method (getName) which returns its name.
0
 
jimmackCommented:
Do you mean java.io.FileDescriptor?

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.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
jimmackCommented:
Hi objects,

   I was trying not to be so blunt with my first point ;-)
0
 
shankiiAuthor Commented:
Hi
What I meant is :

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

 I want to get the file name from this fd.

0
 
objectsCommented:
I know what you meant :)  The FileDescriptor instance knows nothing about the name of the file
0
 
jimmackCommented:
Why would you want to do that?  Why not just store filename?
0
All Courses

From novice to tech pro — start learning today.