Here you can find the source of byteArrayToURL(final byte[] bytes)
static URL byteArrayToURL(final byte[] bytes)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UncheckedIOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; public class Main { static URL byteArrayToURL(final byte[] bytes) { try {/*from w w w.j a v a 2 s . c o m*/ return new URL(null, "foobar://foo/bar", new URLStreamHandler() { @Override protected URLConnection openConnection(final URL u) throws IOException { final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); return new URLConnection(null) { @Override public void connect() throws IOException { } @Override public InputStream getInputStream() throws IOException { return bais; } }; } }); } catch (MalformedURLException e) { throw new UncheckedIOException(e); } } }