Skip to content

Package: Fli4lCompressor

Fli4lCompressor

nameinstructionbranchcomplexitylinemethod
Fli4lCompressor()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createBzip2(InputStream, OutputStream)
M: 0 C: 24
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
createGzip(InputStream, OutputStream)
M: 0 C: 24
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
createLZMA(InputStream, OutputStream)
M: 0 C: 24
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: package archive;
2:
3: import java.io.FileNotFoundException;
4: import java.io.IOException;
5: import java.io.InputStream;
6: import java.io.OutputStream;
7:
8: import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
9: import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
10: import org.apache.commons.compress.compressors.lzma.LZMACompressorOutputStream;
11:
12: import basic.ArchiveConstants;
13:
14: /**
15: * Zustaendig fuer die Komprimierung von Archiven
16: *
17: * @author Gruppe Bau der Installationsarchive III
18: *
19: */
20: public class Fli4lCompressor {
21:
22:         /**
23:          * Komprimierung mit dem Komprimierungsverfahren GZip
24:          *
25:          * @param inputarchive
26:          * @param output
27:          * @throws FileNotFoundException
28:          * @throws IOException
29:          */
30:         public void createGzip(InputStream inputarchive, OutputStream output)
31:                         throws FileNotFoundException, IOException {
32:                 try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(output)) {
33:                         byte[] buffer = new byte[ArchiveConstants.byteBufferConstant];
34:                         int len;
35:•                        while ((len = inputarchive.read(buffer)) != -1) {
36:                                 out.write(buffer, 0, len);
37:                         }
38:                 }
39:         }
40:
41:         /**
42:          * Komprimierung mit dem Komprimierungsverfahren BZip2
43:          *
44:          * @param inputarchive
45:          * @param output
46:          * @throws FileNotFoundException
47:          * @throws IOException
48:          */
49:         public void createBzip2(InputStream inputarchive, OutputStream output)
50:                         throws FileNotFoundException, IOException {
51:                 try (BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(output)) {
52:                         byte[] buffer = new byte[ArchiveConstants.byteBufferConstant];
53:                         int len;
54:•                        while ((len = inputarchive.read(buffer)) != -1) {
55:                                 out.write(buffer, 0, len);
56:                         }
57:                 }
58:         }
59:
60:         /**
61:          * Komprimierung mit dem Komprimierungsverfahren LZMA/ XZ
62:          *
63:          * @param inputarchive
64:          * @param output
65:          * @throws FileNotFoundException
66:          * @throws IOException
67:          */
68:         public void createLZMA(InputStream inputarchive, OutputStream output)
69:                         throws FileNotFoundException, IOException {
70:                 try (LZMACompressorOutputStream out = new LZMACompressorOutputStream(output)) {
71:                         byte[] buffer = new byte[ArchiveConstants.byteBufferConstant];
72:                         int len;
73:•                        while ((len = inputarchive.read(buffer)) != -1) {
74:                                 out.write(buffer, 0, len);
75:                         }
76:                 }
77:         }
78: }