File: GZIPInputStreamMark.java

package info (click to toggle)
king 2.24%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 78,588 kB
  • sloc: java: 111,577; xml: 1,868; cpp: 209; perl: 127; sh: 102; python: 99; makefile: 60; ansic: 7
file content (58 lines) | stat: -rw-r--r-- 2,018 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// (jEdit options) :folding=explicit:collapseFolds=1:
import java.io.*;
import java.util.*;
import java.util.zip.*;
/**
* <code>GZIPInputStreamMark</code> show that a bug exists in
* GZIPInputStream.mark() and GZIPInputStream.reset().
*
* Supply a gzipped file as input on stdin.
*
* <p>Copyright (C) 2003 by Ian W. Davis. All rights reserved.
* <br>Begun on Tue Feb 18 15:05:39 EST 2003
*/
public class GZIPInputStreamMark //extends ... implements ...
{
    public static void main(String[] args) throws IOException
    {
        final int sz = 10, ntests = 3;
        int i, j;
        
        BufferedInputStream buf1 = new BufferedInputStream(System.in);
        System.out.println("buf1.markSupported() == "+buf1.markSupported());
        for(j = 0; j < ntests; j++)
        {
            System.out.print("Test "+(j+1)+": first "+sz+" bytes of stream:");
            buf1.mark(sz);
            for(i = 0; i < sz; i++) System.out.print(" "+buf1.read());
            System.out.println();
            buf1.reset();
        }
        System.out.println();
        
        GZIPInputStream buf2 = new GZIPInputStream(buf1);
        System.out.println("buf2.markSupported() == "+buf2.markSupported());
        for(j = 0; j < ntests; j++)
        {
            System.out.print("Test "+(j+1)+": first "+sz+" bytes of stream:");
            buf2.mark(sz);
            for(i = 0; i < sz; i++) System.out.print(" "+buf2.read());
            System.out.println();
            buf2.reset();
        }
        System.out.println();
        
        BufferedInputStream buf3 = new BufferedInputStream(buf2);
        System.out.println("buf3.markSupported() == "+buf3.markSupported());
        for(j = 0; j < ntests; j++)
        {
            System.out.print("Test "+(j+1)+": first "+sz+" bytes of stream:");
            buf3.mark(sz);
            for(i = 0; i < sz; i++) System.out.print(" "+buf3.read());
            System.out.println();
            buf3.reset();
        }
        System.out.println();
    }
}//class