Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.MalformedURLException; import java.net.URL; public class Main { public static URL toUrl(File file) { try { return file.toURI().toURL(); } catch (final MalformedURLException e) { throw new IllegalArgumentException(e); } } }