InputStream中的文件路径/名称 [英] File path/name from InputStream
本文介绍了InputStream中的文件路径/名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从Java中的InputStream获取文件路径/名称?
How to obtain File Path/Name from an InputStream in Java ?
推荐答案
这是不可能的。(不是来自Java API中的FileInputStream)。 FileInputStream
构造函数不会将此信息存储在任何字段中:
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);
}
这篇关于InputStream中的文件路径/名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文