1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.vfs2.provider.gzip;
18
19 import java.io.InputStream;
20 import java.io.OutputStream;
21 import java.util.zip.GZIPInputStream;
22 import java.util.zip.GZIPOutputStream;
23
24 import org.apache.commons.vfs2.FileObject;
25 import org.apache.commons.vfs2.provider.AbstractFileName;
26 import org.apache.commons.vfs2.provider.compressed.CompressedFileFileObject;
27 import org.apache.commons.vfs2.provider.compressed.CompressedFileFileSystem;
28
29
30
31
32 public class GzipFileObject extends CompressedFileFileObject<GzipFileSystem> {
33
34
35
36
37
38
39
40
41
42
43 @Deprecated
44 protected GzipFileObject(final AbstractFileName name, final FileObject container,
45 final CompressedFileFileSystem fs) {
46 super(name, container, cast(fs));
47 }
48
49 protected GzipFileObject(final AbstractFileName name, final FileObject container, final GzipFileSystem fs) {
50 super(name, container, fs);
51 }
52
53 @Override
54 protected InputStream doGetInputStream(final int bufferSize) throws Exception {
55 return new GZIPInputStream(getContainer().getContent().getInputStream(), bufferSize);
56 }
57
58 @Override
59 protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception {
60 return new GZIPOutputStream(getContainer().getContent().getOutputStream(false));
61 }
62
63 private static GzipFileSystem cast(final CompressedFileFileSystem fs) {
64 if (fs instanceof GzipFileSystem) {
65 return (GzipFileSystem) fs;
66 }
67 throw new IllegalArgumentException("GzipFileObject expects an instance of GzipFileSystem");
68 }
69 }