Resource (final String name) { try { final URL url = new URL(getBaseURL(), name); if (!url.getFile().startsWith(getBaseURL().getFile())) { return null; } final File file = new File(myRootDir, name.replace('/', File.separatorChar)); if (file.exists()) { return new Resource() { @Override public InputStream getInputStream() throws IOException { return new BufferedInputStream(new FileInputStream(file)); } public String toString() { return file.getAbsolutePath(); } }; } } catch (Exception ignored) { } return null; }