gpt4 book ai didi

java - 如何从 FileDescriptor 创建文件?

转载 作者:行者123 更新时间:2023-11-29 05:38:59 27 4
gpt4 key购买 nike

给定一个 FileDescriptor 对象,是否可以通过某种方式从中创建一个 File

谢谢!

最佳答案

不容易,如果有的话。来自documentation :

Instances of the file descriptor class serve as an opaque handle to the underlying machine-specific structure

IFF 您的程序将仅在特定操作系统上运行,您可能会从 FileDescriptor 中的私有(private) fd 字段中提取信息。

例如,在 Linux 上,您可以将其与进程 ID 一起使用以访问 /proc/PID/fd 目录(或编写 JNI 以直接访问该信息)。

也就是说,当然不能移植到其他操作系统。在其他系统上可能会也可能不会做同样的事情。

关于java - 如何从 FileDescriptor 创建文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18383768/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com