Reading a file over a network path

后端 未结 1 1775
故里飘歌
故里飘歌 2020-12-06 11:10

I have this weird issue, when I use

File FileToRead = new File(\"\\\\\\\\MYSERVER\\\\MYFOLDER\\\\MYFOLDER\\\\MYPICTURE.JPG\");

to read a f

相关标签:
1条回答
  • 2020-12-06 11:43

    Just specify the file path as URI:

    File FileToRead = new File(new URI("file://MYSERVER/MYFOLDER/MYFOLDER/MYPICTURE.JPG"));
    

    EDIT note that that string is an URI! It cannot contain spaces so you have to replace them with "%20" to make it work.

    0 讨论(0)
提交回复
热议问题