@Test public void testGet() { URL url = Resources.get("/college.csv"); Assert.assertEquals(Resources.get("/college.csv"), url); }
public static URL get(final String name) { File temp; try { URL url = map.get(name); if(url == null) { temp = File.createTempFile("java-resource", ".tmp"); Path path = Paths.get(temp.getAbsolutePath()); Files.copy(Resources.class.getResourceAsStream(name), path, StandardCopyOption.REPLACE_EXISTING); url = temp.toURI().toURL(); map.put(name, url); return url; } else { return url; } } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } }
Resources { public static URL get(final String name) { File temp; try { URL url = map.get(name); if(url == null) { temp = File.createTempFile("java-resource", ".tmp"); Path path = Paths.get(temp.getAbsolutePath()); Files.copy(Resources.class.getResourceAsStream(name), path, StandardCopyOption.REPLACE_EXISTING); url = temp.toURI().toURL(); map.put(name, url); return url; } else { return url; } } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } } }
Resources { public static URL get(final String name) { File temp; try { URL url = map.get(name); if(url == null) { temp = File.createTempFile("java-resource", ".tmp"); Path path = Paths.get(temp.getAbsolutePath()); Files.copy(Resources.class.getResourceAsStream(name), path, StandardCopyOption.REPLACE_EXISTING); url = temp.toURI().toURL(); map.put(name, url); return url; } else { return url; } } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } }  }
Resources { public static URL get(final String name) { File temp; try { URL url = map.get(name); if(url == null) { temp = File.createTempFile("java-resource", ".tmp"); Path path = Paths.get(temp.getAbsolutePath()); Files.copy(Resources.class.getResourceAsStream(name), path, StandardCopyOption.REPLACE_EXISTING); url = temp.toURI().toURL(); map.put(name, url); return url; } else { return url; } } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } }  static URL get(final String name); static String getAbsolutePath(final String name); }
Resources { public static URL get(final String name) { File temp; try { URL url = map.get(name); if(url == null) { temp = File.createTempFile("java-resource", ".tmp"); Path path = Paths.get(temp.getAbsolutePath()); Files.copy(Resources.class.getResourceAsStream(name), path, StandardCopyOption.REPLACE_EXISTING); url = temp.toURI().toURL(); map.put(name, url); return url; } else { return url; } } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } }  static URL get(final String name); static String getAbsolutePath(final String name);  }