Here you can find the source of FileToURL(File file)
public static URL FileToURL(File file) throws MalformedURLException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.MalformedURLException; import java.net.URL; public class Main { public static URL FileToURL(File file) throws MalformedURLException { return file.toURI().toURL(); }//from w w w . j ava 2 s. c o m }