package org.sufficientlysecure.keychain.testsupport; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; /** * Misc support functions. Would just use Guava / Apache Commons but * avoiding extra dependencies. */ public class TestDataUtil { public static byte[] readFully(InputStream input) { byte[] buffer = new byte[8192]; int bytesRead; ByteArrayOutputStream output = new ByteArrayOutputStream(); try { while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } } catch (IOException e) { throw new RuntimeException(e); } return output.toByteArray(); } }