在Java中如何从网络目录(Windows挂载目录)读取文件
在我的 Windows 电脑中,我有一个名为 p:/projects/file.txt 的已安装网络目录,
当我执行此操作“File f = new File(p:/projects/file.txt)”时,我遇到了文件未找到异常,
我想Java I/O 的本机实现与 Windows 挂钩。
但显然不是,有没有办法这样做?
in my windows pc, I have a mounted network directory called p:/projects/file.txt
I got a file not found exception when I did this "File f = new File(p:/projects/file.txt)"
I thought the Java I/O 's native implementation has a hook with windows.
but apparently its not, is there anyway doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用的真实代码是“File f = new File(C:\files\test.txt)”,网络安装的驱动器位于“P:/projects/file.txt”中,该代码适用于本地驱动器,而不适用于P驱动器
the real code I used is "File f = new File(C:\files\test.txt)" and the network mounted drive is in "P:/projects/file.txt", the code works with local drive, not with the P drive
我知道这已经很旧了,但您意识到 P: 驱动器有正斜杠,C: 驱动器有反斜杠。正斜杠在 Windows 上不起作用。它们在 Linux 或 Unix 系统上运行。
I know this is old, but you realize you've got forward slashes for your P: Drive and back slashes for your C: Drive. Forward slashes don't work on Windows. They do on a linux or Unix system.