Fix stream reading...
This commit is contained in:
parent
fa035c6b2a
commit
f2c4821895
@ -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;
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package eu.mikroskeem.uurimustoo.algoritmidetest.compressors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mark Vainomaa
|
||||||
|
*/
|
||||||
|
public class CompressGZip {
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user