Here you can find the source of getResource(String path)
static InputStream getResource(String path)
//package com.java2s; /*/*from w w w . j a v a2 s . c om*/ * Copyright 2013 John Smith * * This file is part of Willow. * * Willow is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Willow is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Willow. If not, see <http://www.gnu.org/licenses/>. * * Contact details: http://jewelsea.wordpress.com */ import java.io.*; public class Main { /** * Get a resource relative to the application class. */ static InputStream getResource(String path) { //System.out.println( ResourceUtil.class.getResource("../../../../../") );; //return ClassLoader.getSystemResource("../resources/org/jewelsea/willow/" + path).toExternalForm(); InputStream x = ClassLoader.getSystemResourceAsStream("./" + path); if (x != null) return x; try { return new FileInputStream("./data/" + path); } catch (FileNotFoundException e) { e.printStackTrace(); } //return new File("./src/resources/" + path); return null; } }