Code example for InputStream

Methods: available

0
    @Test 
    public void testLoadsURLs() throws Throwable { 
        URL url = resourceClient.getResourceProvider().loadResource("com/acme/foo1");
        assert url != null;
        InputStream stream = url.openStream();
        assert stream.available() > 0;
        InputStreamReader reader = new InputStreamReader(stream);
        char[] chars = new char[4];
        reader.read(chars, 0, 4);
        assert new String(chars).equals("foo1");
        assert url.getFile().endsWith("/com/acme/foo1");
    } 
 
    @Test 
    public void testInitialSlashIgnored() throws Throwable { 
        URL url = resourceClient.getResourceProvider().loadResource("/com/acme/foo1");
        assert url != null;
        InputStream stream = url.openStream();
        assert stream.available() > 0;
        InputStreamReader reader = new InputStreamReader(stream);