@Test void testGetResource() throws Exception { ByteArrayResource resource = new ByteArrayResource("mylocation", new byte[0]); assertNotNull(resource.getResource("mylocation")); assertNull(resource.getResource("notmylocation")); assertTrue(resource.getResource("mylocation").openStream() instanceof ByteArrayInputStream); }
@Override public URL getResource(String location) { URL result = null; if (location != null && location.equals(this.location)) { try { result = new URL(null, "bytes: new ByteArrayResourceURLStreamHandler(this)); } catch (MalformedURLException mue) { } } return result; }
ByteArrayResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null && location.equals(this.location)) { try { result = new URL(null, "bytes: new ByteArrayResourceURLStreamHandler(this)); } catch (MalformedURLException mue) { } } return result; } }
ByteArrayResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null && location.equals(this.location)) { try { result = new URL(null, "bytes: new ByteArrayResourceURLStreamHandler(this)); } catch (MalformedURLException mue) { } } return result; } ByteArrayResource(String location, byte[] bytes); }
ByteArrayResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null && location.equals(this.location)) { try { result = new URL(null, "bytes: new ByteArrayResourceURLStreamHandler(this)); } catch (MalformedURLException mue) { } } return result; } ByteArrayResource(String location, byte[] bytes); @Override Stream<String> getAllLocations(); byte[] getBytes(); @Override URL getResource(String location); @Override InputStream getResourceAsStream(String location); }
ByteArrayResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null && location.equals(this.location)) { try { result = new URL(null, "bytes: new ByteArrayResourceURLStreamHandler(this)); } catch (MalformedURLException mue) { } } return result; } ByteArrayResource(String location, byte[] bytes); @Override Stream<String> getAllLocations(); byte[] getBytes(); @Override URL getResource(String location); @Override InputStream getResourceAsStream(String location);  }