[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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