Java: Get URI from FilePath

前端 未结 5 928
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 17:11

I\'ve little knowledge of Java. I need to construct a string representation of an URI from FilePath(String) on windows. Sometimes the inputFilePath

5条回答
  •  无人及你
    2020-12-03 17:45

    These are the valid file uri:

    file:/C:/a.txt            <- On Windows
    file:///C:/a.txt          <- On Windows
    file:///home/user/a.txt   <- On Linux
    

    So you will need to remove file:/ or file:/// for Windows and file:// for Linux.

提交回复
热议问题