Java: Get URI from FilePath
问题 I've little knowledge of Java. I need to construct a string representation of an URI from FilePath(String) on windows. Sometimes the inputFilePath I get is: file:/C:/a.txt and sometimes it is: C:/a.txt . Right now, what I'm doing is: new File(inputFilePath).toURI().toURL().toExternalForm() The above works fine for paths, which are not prefixed with file:/ , but for paths prefixed with file:/ , the . toURI method is converting it to a invalid URI, by appending value of current dir, and hence