Search code examples
javawicketwicket-6

Wicket: Create IResourceStream for byte[]


I'm using Wicket and I have to implement this method that returns an IResourceStream :

protected IResourceStream getResourceStream() {
        protected IResourceStream getResourceStream() {
            try {
                byte[] data = getMyData(); /* returns a byte[] of data */

                return ???? //What should I use here?
            } catch (Exception e) {
                return null;
            }
        }   

The problem is that I cannot find an implementation of IResourceStream that uses a Byte Array input. All I can find is StringResourceStream which wants a String as input (I tried using that by passing a new String(data), but it corrupts my data) and FileResourceStream that wants a File as input (which I don't have, since I have the data in-memory)

What should I be using here?


Solution

  • You could use AbstractResourceStream that returns ByteArrayInputStream(bytes).

    Feel free to create a ticket at Wicket JIRA if you want this to be included in the distro.