来自 InputStream 的文件路径/名称 [英] File path/name from InputStream

查看:105
本文介绍了来自 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆