- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我成功地使用 VFS 从 HTTP、SFTP、FTP 等下载文件。我需要获取文件的内容类型,但我遇到了一件奇怪的事情,我不确定为什么会发生。
FileObject file = vfs.resolveFile(uri) ;
FileContent content = remote.getContent();
InputStream source = content.getInputStream();
ByteArrayOutputStream target = new ByteArrayOutputStream();
copy(source, target);
content.getSize(); // HACK: Prevents null-pointer in next line
String type = content.getContentInfo().getContentType();
如果我删除对 getSize
的调用,content.getContentInfo
将返回 null。为什么是这样?我错过了什么吗?
最佳答案
正如 @Sam-Rad 所写,它已在主干中修复(即将推出的 VFS 2.1):
关于java - 尝试从 VFS FileObject 获取 ContentInfo 时出现 NullPointer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16302826/
让我们看一段简单的代码: import os f = open('test.bin', 'wb') f.write('X') f.close() # test.bin - X f = open('te
我参与使用 C API 与 Lotus Notes 和 Lotus Domino 交互。我在阅读 NSF 现有注释时遇到了问题。具体来说,读取 TYPE_OBJECT 字段,更具体地说,读取 $FIL
我正在使用 Apache Commons VFS(虚拟文件系统)通过 SFTP 访问一些文件。有人知道如何检查 org.apache.commons.vfs.FileContent 的实例是否是文件夹
我正在尝试使用 org.apache.commons.vfs2 读取远程计算机上的文件。我能够在该机器上找到该文件并将其存储到 FileObject 类中,但我似乎找不到使用该 FileObject
在 NetBeans 平台上创建模块时,FileObject 对象表示 IDE 虚拟文件系统中的文件。创建新的 FileObject 很简单,但是 NetBeans 是否完全控制对实际 File 的引
我是驱动程序开发领域的新手。我正在尝试显示打开的每个文件的路径。我正在使用以下行来显示路径。 PFILE_OBJECT pFileObject = IoGetCurrentIrpStackLocati
我正在使用 Apache Commons VFS2(虚拟文件系统)来监控目录中的更改文件。 org.apache.commons.vfs2.FileListener 返回 org.apache.com
我想编写一个 java 程序来测试一个接口(interface),该接口(interface)通过 SFTP 通过 xml 文件进行通信。该接口(interface)的想法是,一侧上传一个 xml 文
我成功地使用 VFS 从 HTTP、SFTP、FTP 等下载文件。我需要获取文件的内容类型,但我遇到了一件奇怪的事情,我不确定为什么会发生。 FileObject file = vfs.resolve
我正在尝试监视一个文件夹中的批处理文件,该文件将被拖放到那里以更新网络应用程序。该应用程序已经使用了 Apache vfs2 库,我的领导建议我也使用它。 我的问题是:java.io 中的 File
我一直在寻找一种解决方案,通过事件跟踪 (ETW) session 中的特定进程获取所有读/写/打开/关闭文件(我将处理来自实时 session 的数据)。我编写这段代码并获取该操作中的所有事件,但我
我是一名优秀的程序员,十分优秀!