Fix stream reading...

This commit is contained in:
Mark Vainomaa 2017-03-26 17:33:35 +03:00
parent fa035c6b2a
commit f2c4821895
2 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,6 @@
package eu.mikroskeem.uurimustoo.algoritmidetest.compressors; package eu.mikroskeem.uurimustoo.algoritmidetest.compressors;
import eu.mikroskeem.shuriken.common.SneakyThrow; import eu.mikroskeem.shuriken.common.SneakyThrow;
import org.tukaani.xz.FinishableOutputStream;
import java.io.*; import java.io.*;
@ -24,11 +23,11 @@ public abstract class AbstractCompressor {
} }
public void pipe0(InputStream inputStream, OutputStream outputStream) throws IOException { public void pipe0(InputStream inputStream, OutputStream outputStream) throws IOException {
OutputStream out = pipe(outputStream); try(OutputStream out = pipe(outputStream)) {
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
int s; while((s = inputStream.read()) != -1) out.write(buf, 0, s); int s; while ((s = inputStream.read(buf)) != -1) out.write(buf, 0, s);
if(out instanceof FinishableOutputStream) out.flush();
((FinishableOutputStream) out).finish(); }
} }
public abstract OutputStream pipe(OutputStream outputStream) throws IOException; public abstract OutputStream pipe(OutputStream outputStream) throws IOException;

View File

@ -0,0 +1,7 @@
package eu.mikroskeem.uurimustoo.algoritmidetest.compressors;
/**
* @author Mark Vainomaa
*/
public class CompressGZip {
}