I have a school assignment that requires my to take in an inputstream and compress it into a byte array with one of 5 formats (by the user specification) using the apache commons compress library. The 5 formats are: ZIP, JAR, SEVENZ, BZIP2 and GZIP. I wrote the following method to compress the input stream with the JAR format but am getting an illegalStateException with the string "No current entry".
private byte[] documentJARCompression(InputStream in) throws IOException {
BufferedInputStream buffIn = new BufferedInputStream(in);
ByteArrayOutputStream out = new ByteArrayOutputStream();
JarArchiveOutputStream jarOut = new JarArchiveOutputStream(out);
final byte[] buffer = new byte[out.size()];
int n = 0;
while (-1 != (n = buffIn.read(buffer))) {
jarOut.write(buffer, 0, n);
}
jarOut.close();
return buffer;
}