Java tutorial
import java.io.File; import java.net.MalformedURLException; import java.net.URL; public class Main { public static void main(String[] args) { File f = new File("c:/a/b/a/test.txt"); URL uri; try { uri = f.toURL(); System.out.println("uri: " + uri); } catch (MalformedURLException e) { e.printStackTrace(); } } }