• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

File name from file descriptor

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

Thanks
0
shankii
Asked:
shankii
1 Solution
 
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
 
objectsCommented:
You can't.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Tackle projects and never again get stuck behind a technical roadblock.
Join Now