I am trying to open a file from a URL.
The URL object is created using the getResource () method of the ClassLoader class. The output URL returned by getResource () is =
file:/C:/users/
After using the URL.getFile () method, which returns String as "/ C: / users /", it deletes " file: " just not " / This / gives me an error opening the file using the new FileInputStream. Error: FileNotFoundException
The "/" at the beginning of the file name causes the same problem when getting the path object. Here, the directory value is retrieved from URL.getResource (). Getfile ()
Path Dest = Paths.get (Directory);
Received error: java.nio.file.InvalidPathException: Illegal char <:> at index 2: / C: / Users /
Does anyone encounter such a problem?
java-7
user3243318
source share