how can you retrieve a local file using "java.nio.file.Paths" for java 7 or any other API . I have this line of code but it returns the wrong directory format.
public static InputStream readfile(String filename) throws FileNotFoundException
{
persistenceService = (PersistenceService) ServiceManager.lookup(PersistenceService.class.getCanonicalName());
URL url = Paths.get(filename).toUri().toURL();
FileContents fileContents = persistenceService.get(url);
Result when printing url is:
file:/C:/Users/username/Desktop/filedirectory/filename
Supposed to be:
file:C:/Users/username/Desktop/filedirectory/filename
How can I get rid of that first /
or is this a wrong method?
Copied the two URLs in a windows explorer, the first one opens a webpage and cannot display, the second one opens the file I need.