- Java.util.zip 包类
- Java.util.zip - 主页
- Java.util.zip - Adler32
- Java.util.zip - CheckedInputStream
- Java.util.zip - CheckedOutputStream
- Java.util.zip - CRC32
- Java.util.zip - Deflater
- Java.util.zip - DeflaterInputStream
- Java.util.zip - DeflaterOutputStream
- Java.util.zip - GZIPInputStream
- Java.util.zip - GZIPOutputStream
- Java.util.zip - Inflater
- Java.util.zip - InflaterInputStream
- Java.util.zip - InflaterOutputStream
- Java.util.zip - ZipEntry
- Java.util.zip - ZipFile
- Java.util.zip - ZipInputStream
- Java.util.zip - ZipOutputStream
- Java.util.zip 包附加信息
- Java.util.zip - 异常
- Java.util.zip - 错误
- Java.util.zip 实用资源
- Java.util.zip - 快速指南
- Java.util.zip - 实用资源
- java.util.zip - 讨论
Java.util.zip.Inflater.markSupported() 方法示例
描述
java.util.zip.InflaterInputStream.markSupported() 方法测试此输入流是否支持标记和重置方法。InflaterInputStream 的 markSupported 方法返回 false。
声明
以下是 java.util.zip.InflaterInputStream.markSupported() 方法的声明。
public boolean markSupported()
返回
一个布尔值,指示此流类型是否支持标记和重置方法。
示例
以下示例展示了 java.util.zip.InflaterInputStream.markSupported() 方法的用法。
package com.tutorialspoint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.InflaterInputStream; public class InflaterInputStreamDemo { public static void main(String[] args) throws DataFormatException, IOException { String message = "Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;" +"Welcome to TutorialsPoint.com;"; System.out.println("Original Message length : " + message.length()); byte[] input = message.getBytes("UTF-8"); int length = message.length(); // Compress the bytes byte[] output = new byte[1024]; Deflater deflater = new Deflater(); deflater.setInput(input); deflater.finish(); int compressedDataLength = deflater.deflate(output,0 , output.length, Deflater.NO_FLUSH); System.out.println("Total uncompressed bytes input :" + deflater.getTotalIn()); System.out.println("Compressed Message Checksum :" + deflater.getAdler()); deflater.finished(); System.out.println("Compressed Message length : " + compressedDataLength); ByteArrayInputStream bin = new ByteArrayInputStream(output); InflaterInputStream inflaterInputStream = new InflaterInputStream(bin); byte[] result = new byte[1024]; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); if(inflaterInputStream.markSupported()){ inflaterInputStream.mark(0); } if(inflaterInputStream.markSupported()){ inflaterInputStream.reset(); } while(inflaterInputStream.available() != 0){ buffer.write(inflaterInputStream.read()); } inflaterInputStream.close(); // Decode the bytes into a String String message1 = new String(buffer.toByteArray(),0, length,"UTF-8"); System.out.println(message.equals(message1)); } }
让我们编译和运行上述程序,这将产生以下结果 −
Original Message length : 300 Total uncompressed bytes input :300 Compressed Message Checksum :368538129 Compressed Message length : 42 true
javazip_inflaterinputstream.htm
广告