我需要安全地锁定 Windows 上的 Java 桌面应用程序,以便只能访问允许的驱动器。
如何阻止应用程序上的 JFilechooser 显示和浏览本地网络?
我已尝试应用安全策略,但这似乎不会影响显示。
最佳答案
使用JFileChooser.setFileSystemView(FileSystemView)
。 FileSystemView
..
..is
JFileChooser's
gateway to the file system. Since the JDK1.1 File API doesn't allow access to such information as root partitions, file type information, or hidden file bits, this class is designed to intuit as much OS-specific file system information as possible. Java Licensees may want to provide a different implementation ofFileSystemView
to better handle a given operating system.
重要的部分是改变 isTraversable(File)
的行为方法。
关于java - JFileChooser网络显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31166150/