Get URI from File in Java
Description
The following code shows how to get URI from File.
Example
/*from ww w . ja v a2 s .c o m*/
import java.io.File;
public class Main {
public static void main(String args[]) {
try {
File testFile = new File("C:\\books\\2004\\test.txt");
System.out.println(testFile.toURI().toString());
} catch (Exception exception) {
System.out.println("exception");
}
}
}
The code above generates the following result.