public static byte[] loadFromStream(InputStream inputStream) throws IOException { final UnsyncByteArrayOutputStream outputStream = new UnsyncByteArrayOutputStream(); try { copyStreamContent(inputStream, outputStream); } finally { inputStream.close(); } return outputStream.toByteArray(); }
public void saveContent(@Nonnull String fileSpec, @Nonnull RoamingType roamingType, byte[] content, int size) throws IOException { UnsyncByteArrayOutputStream out = new UnsyncByteArrayOutputStream(size); try (SnappyOutputStream snappyOutputStream = new SnappyOutputStream(out)) { snappyOutputStream.write(content, 0, size); } byte[] compressedContent = out.toByteArray(); myQueue.wantSave(myProxyDirectory, fileSpec, roamingType, compressedContent); }