< prev index next >

test/java/util/zip/GZIP/GZIPInputStreamRead.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4691425
  26  * @summary Test the read and write of GZIPInput/OutputStream, including
  27  *          concatenated .gz inputstream

  28  */
  29 
  30 import java.io.*;
  31 import java.util.*;
  32 import java.util.zip.*;
  33 
  34 public class GZIPInputStreamRead {
  35     public static void main(String[] args) throws Throwable {
  36         Random rnd = new Random();
  37         for (int i = 1; i < 100; i++) {
  38             int members = rnd.nextInt(10) + 1;
  39 
  40             ByteArrayOutputStream srcBAOS = new ByteArrayOutputStream();
  41             ByteArrayOutputStream dstBAOS = new ByteArrayOutputStream();
  42             for (int j = 0; j < members; j++) {
  43                 byte[] src = new byte[rnd.nextInt(8192) + 1];
  44                 rnd.nextBytes(src);
  45                 srcBAOS.write(src);
  46 
  47                 try (GZIPOutputStream gzos = new GZIPOutputStream(dstBAOS)) {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4691425
  26  * @summary Test the read and write of GZIPInput/OutputStream, including
  27  *          concatenated .gz inputstream
  28  * @key randomness
  29  */
  30 
  31 import java.io.*;
  32 import java.util.*;
  33 import java.util.zip.*;
  34 
  35 public class GZIPInputStreamRead {
  36     public static void main(String[] args) throws Throwable {
  37         Random rnd = new Random();
  38         for (int i = 1; i < 100; i++) {
  39             int members = rnd.nextInt(10) + 1;
  40 
  41             ByteArrayOutputStream srcBAOS = new ByteArrayOutputStream();
  42             ByteArrayOutputStream dstBAOS = new ByteArrayOutputStream();
  43             for (int j = 0; j < members; j++) {
  44                 byte[] src = new byte[rnd.nextInt(8192) + 1];
  45                 rnd.nextBytes(src);
  46                 srcBAOS.write(src);
  47 
  48                 try (GZIPOutputStream gzos = new GZIPOutputStream(dstBAOS)) {


< prev index next >