KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 the path becomes invalid. Please help me out by suggesting a correct way to get the proper URI for both kind of paths.
Tags (comma-separated)
Save Edits
Cancel