Use Input/Outputstream classes instead of own implementation
This commit is contained in:
parent
861dd06286
commit
6c79bf8514
@ -1,10 +1,14 @@
|
|||||||
package eu.mikroskeem.uurimustoo.algoritmidetest.algoritmid;
|
package eu.mikroskeem.uurimustoo.algoritmidetest.algoritmid;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.meteogroup.jbrotli.BrotliStreamCompressor;
|
import org.meteogroup.jbrotli.io.BrotliInputStream;
|
||||||
import org.meteogroup.jbrotli.BrotliStreamDeCompressor;
|
import org.meteogroup.jbrotli.io.BrotliOutputStream;
|
||||||
import org.meteogroup.jbrotli.libloader.BrotliLibraryLoader;
|
import org.meteogroup.jbrotli.libloader.BrotliLibraryLoader;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mark Vainomaa
|
* @author Mark Vainomaa
|
||||||
*/
|
*/
|
||||||
@ -16,16 +20,12 @@ public class Brotli extends AbstractAlgorithm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] compress(byte[] input) {
|
public OutputStream createCompressor(OutputStream outputStream) throws IOException {
|
||||||
BrotliStreamCompressor compressor = new BrotliStreamCompressor();
|
return new BrotliOutputStream(outputStream);
|
||||||
return compressor.compressArray(input, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] decompress(byte[] input) {
|
public InputStream createDecompressor(InputStream inputStream) throws IOException {
|
||||||
BrotliStreamDeCompressor decompressor = new BrotliStreamDeCompressor();
|
return new BrotliInputStream(inputStream);
|
||||||
byte[] buf = new byte[8192]; // *sigh*
|
|
||||||
decompressor.deCompress(input, buf);
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user