有没有办法让外部设备出现在 JavaFx DirectoryChooser 的对话框上? 如果没有,有其他选择吗?
我需要做的是通过java应用程序将文件从PC复制/粘贴到Android手机SD卡中的目录。 由于我使用的是 javaFx,我尝试使用 DirectoryChooser 选择目标文件夹,但它似乎没有检测到设备。
最佳答案
据我所知,手机应该设置为 USB 存储而不是 MTP(媒体传输协议(protocol)),以便能够使用 JavaFX 文件/目录浏览器找到它。 (这意味着例如在 Windows 上会显示驱动器号)。
Swing JFileChooser 也出现同样的问题:Android and JFileChooser
还有 DirectoryChooser 的文档JavaFX 状态:
On some platforms where file access may be restricted or not part of the user model (for example, on some mobile or embedded devices), opening a directory dialog may always result in a no-op (that is, null file being returned).
关于java - 使用 DirectoryChooser 选择外部设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37391421/