@Test public void parse() throws IOException { File testFile = File.createTempFile("resources", "test"); Resource resource = Resources.parse(testFile.getPath(), null); try { resource.open(); } catch (IOException ioe) { fail(ioe.getMessage()); } finally { resource.close(); } File withinHome = new File(FileUtil.pathFromParts(System.getProperty("user.home"), "test.txt")); withinHome.createNewFile(); withinHome.deleteOnExit(); resource = Resources.parse(FileUtil.pathFromParts("~", "test.txt"), null); try { resource.open(); } catch (IOException ioe) { fail(ioe.getMessage()); } finally { resource.close(); } resource = Resources.parse("file: try { resource.open(); } catch (IOException ioe) { fail(ioe.getMessage()); } finally { resource.close(); } resource = Resources.parse("http: try { resource.open(); } catch (IOException ioe) { fail(ioe.getMessage()); } finally { resource.close(); } resource = Resources.parse("classpath:mock-mvn-repo/commons-logging/commons-logging/1.1.1/maven-metadata.xml", null); try { resource.open(); } catch (IOException ioe) { fail(ioe.getMessage()); } finally { resource.close(); } }
public static Resource parse(String resource, Map<String, String> headers) { if (resource == null) { return null; } else if (resource.startsWith("http:") || resource.startsWith("https:")) { try { return new UrlResource(resource, headers); } catch (MalformedURLException murle) { throw new RuntimeException(murle); } } else if (resource.startsWith("classpath:")) { return new ClasspathResource(resource.substring(10), LOADER.get()); } else { return new FileResource(resource); } }
Resources { public static Resource parse(String resource, Map<String, String> headers) { if (resource == null) { return null; } else if (resource.startsWith("http:") || resource.startsWith("https:")) { try { return new UrlResource(resource, headers); } catch (MalformedURLException murle) { throw new RuntimeException(murle); } } else if (resource.startsWith("classpath:")) { return new ClasspathResource(resource.substring(10), LOADER.get()); } else { return new FileResource(resource); } } }
Resources { public static Resource parse(String resource, Map<String, String> headers) { if (resource == null) { return null; } else if (resource.startsWith("http:") || resource.startsWith("https:")) { try { return new UrlResource(resource, headers); } catch (MalformedURLException murle) { throw new RuntimeException(murle); } } else if (resource.startsWith("classpath:")) { return new ClasspathResource(resource.substring(10), LOADER.get()); } else { return new FileResource(resource); } } private  Resources(); }
Resources { public static Resource parse(String resource, Map<String, String> headers) { if (resource == null) { return null; } else if (resource.startsWith("http:") || resource.startsWith("https:")) { try { return new UrlResource(resource, headers); } catch (MalformedURLException murle) { throw new RuntimeException(murle); } } else if (resource.startsWith("classpath:")) { return new ClasspathResource(resource.substring(10), LOADER.get()); } else { return new FileResource(resource); } } private  Resources(); static void setResourcesLoader(ClassLoader classLoader); static Resource parse(String resource, Map<String, String> headers); }
Resources { public static Resource parse(String resource, Map<String, String> headers) { if (resource == null) { return null; } else if (resource.startsWith("http:") || resource.startsWith("https:")) { try { return new UrlResource(resource, headers); } catch (MalformedURLException murle) { throw new RuntimeException(murle); } } else if (resource.startsWith("classpath:")) { return new ClasspathResource(resource.substring(10), LOADER.get()); } else { return new FileResource(resource); } } private  Resources(); static void setResourcesLoader(ClassLoader classLoader); static Resource parse(String resource, Map<String, String> headers);  }