Alex Rivera | Logout

File path/name from InputStream

Asked 2010-03-23T17:00:23.603
16

How to obtain File Path/Name from an InputStream in Java ?

Edit
Report

1 Answer

13

It's not possible. (not from the FileInputStream in the Java API). The FileInputStream constructor does not store this information in any field:

public FileInputStream(File file) throws FileNotFoundException {
    String name = (file != null ? file.getPath() : null);
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkRead(name);
    }
        if (name == null) {
            throw new NullPointerException();
        }
    fd = new FileDescriptor();
    open(name);
    }
answered 2010-03-23T17:06:41.433

Your Answer