Tag: unc

使用Java NIO直接访问Windows磁盘

我正在使用一个使用Java NIO的库,以便直接将文件映射到内存,但是我无法直接读取磁盘。 我可以使用带有UNC的FileInputStream直接读取磁盘,例如 File disk = new File(“\\\\.\\PhysicalDrive0\\”); try (FileInputStream fis = new FileInputStream(disk); BufferedInputStream bis = new BufferedInputStream(fis)) { byte[] somebytes = new byte[10]; bis.read(somebytes); } catch (Exception ex) { System.out.println(“Oh bother”); } 但是,我无法将其扩展到NIO: File disk = new File(“\\\\.\\PhysicalDrive0\\”); Path path = disk.toPath(); try (FileChannel fc = FileChannel.open(path, StandardOpenOption.READ)){ System.out.println(“No exceptions! Yay!”); } catch […]

如何从JFileChooser检索UNC路径而不是映射驱动器路径

只是想知道是否有办法从使用JFileChooser选择的文件返回UNC路径。 我将选择的文件将驻留在具有UNC路径的映射驱动器上。 现在,我似乎只能拉回映射驱动器的驱动器号。

如何在Java中安装Windows驱动器?

我们正在处理一些通过字母访问共享驱动器的遗留代码(例如f:\)。 使用UNC表示法不是一种选择。 我们的Java包装器应用程序将作为服务运行,作为第一步,我想在代码中显式映射驱动器。 有没有人这样做过?