This make a copy of the byte array which is bad. Do this instead:

    ptr.get(byteStream.getBuffer(),0,byteStream.getSize());