Here you can find the source of getResource(String strName)
Parameter | Description |
---|---|
strName | String |
Parameter | Description |
---|---|
Exception | an exception |
// ////////////////////////////////////////////////////// public static java.net.URL getResource(String strName)
import java.io.*; import java.text.SimpleDateFormat; import java.util.Date; public class Main{ /**/* w w w. j av a 2 s . co m*/ * Return resource from local file, if false then search from classpath * * @param strName * String * @return InputStream * @throws Exception */ // ////////////////////////////////////////////////////// public static java.net.URL getResource(String strName) { try { File fl = new File(strName); if (fl.exists() && fl.isFile()) return fl.toURI().toURL(); } catch (Exception e) { } if (!strName.startsWith("/")) return FileUtil.class.getResource("/" + strName); else return FileUtil.class.getResource(strName); } }