KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > io > archive > tar > TarGZipDriver


1 /*
2  * TarGZipDriver.java
3  *
4  * Created on 24. Dezember 2005, 00:01
5  */

6 /*
7  * Copyright 2006 Schlichtherle IT Services
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package de.schlichtherle.io.archive.tar;
23
24 import de.schlichtherle.io.archive.Archive;
25 import de.schlichtherle.io.archive.spi.InputArchive;
26 import de.schlichtherle.io.archive.spi.OutputArchive;
27 import de.schlichtherle.io.rof.ReadOnlyFile;
28
29 import java.io.IOException JavaDoc;
30 import java.io.InputStream JavaDoc;
31 import java.io.OutputStream JavaDoc;
32 import java.util.zip.GZIPInputStream JavaDoc;
33 import java.util.zip.GZIPOutputStream JavaDoc;
34
35 /**
36  * An archive driver which builds TAR archives compressed with GZIP.
37  * Instances of this class are immutable.
38  *
39  * @author Christian Schlichtherle
40  * @version @version@
41  * @since TrueZIP 6.0
42  */

43 public class TarGZipDriver extends TarDriver {
44
45     private static final int BUFSIZE = 4096;
46
47     /**
48      * Equivalent to {@link TarDriver#TarDriver(String, Icon, Icon)
49      * super(ENCODING, null, null)}.
50      * These parameters are based on heuristics.
51      */

52     public TarGZipDriver() {
53         super(ENCODING, null, null);
54     }
55
56     /**
57      * Equivalent to {@link TarDriver#TarDriver(String, Icon, Icon)
58      * super(encoding, null, null)}.
59      * These parameters are based on heuristics.
60      * <p>
61      * Warning: The encoding parameter is currently not yet supported by this
62      * driver!
63      */

64     public TarGZipDriver(String JavaDoc encoding) {
65         super(encoding, null, null);
66     }
67
68     //
69
// Driver implementation:
70
//
71

72     protected InputStream JavaDoc createInputStream(ReadOnlyFile rof)
73     throws IOException JavaDoc {
74         return new GZIPInputStream JavaDoc(super.createInputStream(rof), BUFSIZE);
75     }
76
77     public OutputArchive createOutputArchive(
78             final Archive archive,
79             final OutputStream JavaDoc out,
80             final InputArchive source)
81     throws IOException JavaDoc {
82         return super.createOutputArchive(
83                 archive, new GZIPOutputStream JavaDoc(out, BUFSIZE), source);
84     }
85 }
86
Popular Tags