|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
| 개요: 상자 | 필드 | 생성자 | 메소드 | 상세 : 필드 | 생성자 | 메소드 | |||||||||
java.lang.Objectjava.util.zip.Deflater
public class Deflater
이 클래스는, 일반적인 ZLIB 압축 라이브러리를 사용해 범용의 압축 알고리즘을 지원합니다. ZLIB 압축 라이브러리는, 당초 PNG 그래픽 표준의 일부로서 개발된 것으로, 특허로는 보호되고 있지 않습니다. 스펙의 자세한 것은,「패키지 java.util.zip 의 설명」을 참조해 주세요.
다음에,Deflater 및 Inflater 를 사용해 캐릭터 라인을 얼마인가 압축 및 압축 해제하는 코드를 나타냅니다.
try {
// Encode a String into bytes
String inputString = "blahblahblah??";
byte[] input = inputString.getBytes("UTF-8");
// Compress the bytes
byte[] output = new byte[100];
Deflater compresser = new Deflater();
compresser.setInput(input);
compresser.finish();
int compressedDataLength = compresser.deflate(output);
// Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(output, 0, compressedDataLength);
byte[] result = new byte[100];
int resultLength = decompresser.inflate(result);
decompresser.end();
// Decode the bytes into a String
String outputString = new String(result, 0, resultLength, "UTF-8");
} catch(java.io.UnsupportedEncodingException ex) {
// handle
} catch (java.util.zip.DataFormatException ex) {
// handle
}
Inflater | 필드의 개요 | |
|---|---|
static int |
BEST_COMPRESSION
최적인 압축을 위한 압축 레벨입니다. |
static int |
BEST_SPEED
최고속에서의 압축을 위한 압축 레벨입니다. |
static int |
DEFAULT_COMPRESSION
디폴트의 압축 레벨입니다. |
static int |
DEFAULT_STRATEGY
디폴트의 압축 방법입니다. |
static int |
DEFLATED
deflate 알고리즘의 압축 메소드 (현재 지원되고 있는 것은 1 개(살) 뿐)입니다. |
static int |
FILTERED
작은 값이 어느 정도 랜덤에 분포하고 있는 데이터에 최적인 압축 방법입니다. |
static int |
HUFFMAN_ONLY
하프맨 코딩 전용의 압축 방법입니다. |
static int |
NO_COMPRESSION
압축하지 않는 경우의 압축 레벨입니다. |
| 생성자 의 개요 | |
|---|---|
Deflater ()
디폴트의 압축 레벨로 새로운 압력을 작성합니다. |
|
Deflater (int level)
지정된 압축 레벨로 새로운 압력을 작성합니다. |
|
Deflater (int level,
boolean nowrap)
지정된 압축 레벨로 새로운 압력을 작성합니다. |
|
| 메소드의 개요 | |
|---|---|
int |
deflate (byte[] b)
지정된 버퍼를 압축 데이터로 채웁니다. |
int |
deflate (byte[] b,
int off,
int len)
지정된 버퍼를 압축 데이터로 채웁니다. |
void |
end ()
압력을 닫아 압축 해제된 입력을 모두 파기합니다. |
protected void |
finalize ()
가베지 컬렉션을 했을 때에 압력을 닫습니다. |
void |
finish ()
이 메소드가 불려 가면(자), 압축이 입력 버퍼의 현재의 내용으로 종료할 필요가 있는 것을 나타냅니다. |
boolean |
finished ()
압축 데이터의 출력 스트림의 마지막에 달했을 경우에 true 를 돌려줍니다. |
int |
getAdler ()
압축 해제 데이터의 ADLER-32 치를 돌려줍니다. |
long |
getBytesRead ()
지금까지 입력된, 압축 해제된 바이트의 총수를 돌려줍니다. |
long |
getBytesWritten ()
지금까지 출력된, 압축된 바이트의 총수를 돌려줍니다. |
int |
getTotalIn ()
지금까지 입력된, 압축 해제된 바이트의 총수를 돌려줍니다. |
int |
getTotalOut ()
지금까지 출력된, 압축된 바이트의 총수를 돌려줍니다. |
boolean |
needsInput ()
입력 데이터 버퍼가 빈 상태(empty)이기 (위해)때문에, setInput()를 호출해 입력을 추가할 필요가 있는 경우에 true 를 돌려줍니다. |
void |
reset ()
새로운 입력 데이터세트를 처리할 수 있도록(듯이) 디플렉터를 리셋 합니다. |
void |
setDictionary (byte[] b)
압축을 위한 pre-set 사전를 설정합니다. |
void |
setDictionary (byte[] b,
int off,
int len)
압축을 위한 pre-set 사전를 설정합니다. |
void |
setInput (byte[] b)
압축을 위한 입력 데이터를 설정합니다. |
void |
setInput (byte[] b,
int off,
int len)
압축을 위한 입력 데이터를 설정합니다. |
void |
setLevel (int level)
현재의 압축 레벨이 지정된 값으로 설정합니다. |
void |
setStrategy (int strategy)
압축 방법이 지정된 값으로 설정합니다. |
| 클래스 java.lang. Object 로부터 상속된 메소드 |
|---|
clone , equals , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
| 필드의 상세 |
|---|
public static final int DEFLATED
public static final int NO_COMPRESSION
public static final int BEST_SPEED
public static final int BEST_COMPRESSION
public static final int DEFAULT_COMPRESSION
public static final int FILTERED
public static final int HUFFMAN_ONLY
public static final int DEFAULT_STRATEGY
| 생성자 의 상세 |
|---|
public Deflater(int level,
boolean nowrap)
level - 압축 레벨 (0 ~ 9)nowrap - true 의 경우는 GZIP 호환의 압축을 사용public Deflater(int level)
level - 압축 레벨 (0 ~ 9)public Deflater()
| 메소드의 상세 |
|---|
public void setInput(byte[] b,
int off,
int len)
b - 입력 데이터 바이트off - 데이터의 개시 오프셋(offset)len - 데이터의 길이needsInput() public void setInput(byte[] b)
b - 입력 데이터 바이트needsInput()
public void setDictionary(byte[] b,
int off,
int len)
b - 사전 데이터 바이트off - 데이터의 개시 오프셋(offset)len - 데이터의 길이Inflater.inflate(byte[], int, int) ,
Inflater.getAdler() public void setDictionary(byte[] b)
b - 사전 데이터 바이트Inflater.inflate(byte[], int, int) ,
Inflater.getAdler() public void setStrategy(int strategy)
strategy - 새로운 압축 방법
IllegalArgumentException - 압축 방법이 무효인 경우public void setLevel(int level)
level - 새로운 압축 레벨 (0 ~ 9)
IllegalArgumentException - 압축 레벨이 무효인 경우public boolean needsInput()
public void finish()
public boolean finished()
public int deflate(byte[] b,
int off,
int len)
b - 압축 데이터용의 버퍼off - 데이터의 개시 오프셋(offset)len - 압축 데이터의 최대 바이트수
public int deflate(byte[] b)
b - 압축 데이터용의 버퍼
public int getAdler()
public int getTotalIn()
바이트수는 Integer.MAX_VALUE 보다 커지는 경우가 있기 (위해)때문에, 이 정보를 얻는 경우는 getBytesRead() 메소드의 (분)편을 우선적으로 사용해 주세요.
public long getBytesRead()
public int getTotalOut()
바이트수는 Integer.MAX_VALUE 보다 커지는 경우가 있기 (위해)때문에, 이 정보를 얻는 경우는 getBytesWritten() 메소드의 (분)편을 우선적으로 사용해 주세요.
public long getBytesWritten()
public void reset()
public void end()
protected void finalize()
Object 내의 finalize
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
| 개요: 상자 | 필드 | 생성자 | 메소드 | 상세 : 필드 | 생성자 | 메소드 | |||||||||
Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.