Link to home
Start Free TrialLog in
Avatar of shankii
shankii

asked on

File name from file descriptor

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

Thanks
Avatar of imladris
imladris
Flag of Canada image

What do you mean by a "file descriptor" exactly?

Certainly a File object has a method (getName) which returns its name.
Avatar of jimmack
jimmack

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.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi objects,

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

ASKER

Hi
What I meant is :

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

 I want to get the file name from this fd.

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