static HeapResource load(final URL resource) throws IOException {
        try (final InputStream in = resource.openStream()) {
            final ByteArrayBuffer buf = new ByteArrayBuffer(1024);
            final byte[] tmp = new byte[2048];
            int len;
            while ((len = in.read(tmp)) != -1) {
                buf.append(tmp, 0, len);
            }
            return new HeapResource(buf.toByteArray());
        }
    }
Deserialize cache entries with trailing garbage.
httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java