How to obtain File Path/Name from an InputStream in Java ?
+2
A:
You can't because the InputStream
might not have been a file or path. You can implement your own InputStream
that generates data on the fly
Pyrolistical
2010-03-23 17:04:10
+1
A:
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);
}
Bruno Rothgiesser
2010-03-23 17:06:41