Here you can find the source of getFile(Class base, String path)
@SuppressWarnings("rawtypes") public static File getFile(Class base, String path)
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; public class Main { @SuppressWarnings("rawtypes") public static File getFile(Class base, String path) { return urlToFile(base.getResource(path)); }// w w w. j a va2s. c o m public static File urlToFile(URL url) { if (url == null) { return null; } File file = null; try { file = new File(new URI(url.toExternalForm())); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.toString()); } return file; } }