在文件名路径和URL之间转换
/* n o w j a v a . c o m - 时代Java */ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; public class Main { public static void main(String[] args) throws Exception { File file = new File("filename"); URL url = null; try { url = file.toURL(); // file:/d:/folder1.4/java.io/filename/*来自 NowJava.com - 时代Java*/ } catch (MalformedURLException e) { } file = new File(url.getFile()); // d:/folder1.4/java.io/filename try { InputStream is = url.openStream(