Solved

File name from file descriptor

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

Thanks
0
Comment
Question by:shankii
9 Comments
 
LVL 16

Expert Comment

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

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

Expert Comment

by:jimmack
ID: 9660951
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
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 9661403
You can't.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 15

Expert Comment

by:jimmack
ID: 9661463
Hi objects,

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

Author Comment

by:shankii
ID: 9661477
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
 
LVL 92

Expert Comment

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

Expert Comment

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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
even odd program using while loop 3 60
jdbc error in jsp application 20 63
running on tomcat not jboss eap 7.0 3 17
Tagging and Merging on Branch 1 29
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

789 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