java – 来自InputStream的文件路径/名称
发布时间:2020-12-14 05:32:34 所属栏目:Java 来源:网络整理
导读:如何从 Java中的InputStream获取文件路径/名称? 解决方法 这是不可能的. (不是Java API中的FileInputStream). FileInputStream构造函数不会将此信息存储在任何字段中: public FileInputStream(File file) throws FileNotFoundException { String name = (f
如何从
Java中的InputStream获取文件路径/名称?
解决方法
这是不可能的. (不是Java API中的FileInputStream). FileInputStream构造函数不会将此信息存储在任何字段中:
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); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |