java.lang.Objectjava.util.zip.Inflater
public class Inflater
This class provides support for general purpose decompression using the popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description.
The following code fragment demonstrates a trivial compression and decompression of a string using Deflater and Inflater.
// Encode a String into bytes byte[] input = inputString.getBytes("UTF-8"); // Compress the bytes byte[] output = new byte[100]; compresser.setInput(input); compresser.finish(); int compressedDataLength = compresser.deflate(output); // Decompress the bytes decompresser.setInput(output, 0, compressedDataLength); byte[] result = new byte[100]; int resultLength = decompresser.inflate(result); decompresser.end(); // Decode the bytes into a String
Deflater| Constructor Summary | |
|---|---|
Inflater()
Creates a new decompressor. |
|
Inflater(boolean nowrap)
Creates a new decompressor. |
|
| Method Summary | |
|---|---|
void |
end()
Closes the decompressor and discards any unprocessed input. |
protected void |
finalize()
Closes the decompressor when garbage is collected. |
boolean |
finished()
Returns true if the end of the compressed data stream has been reached. |
int |
getAdler()
Returns the ADLER-32 value of the uncompressed data. |
long |
getBytesRead()
Returns the total number of compressed bytes input so far. |
long |
getBytesWritten()
Returns the total number of uncompressed bytes output so far. |
int |
getRemaining()
Returns the total number of bytes remaining in the input buffer. |
int |
getTotalIn()
Returns the total number of compressed bytes input so far. |
int |
getTotalOut()
Returns the total number of uncompressed bytes output so far. |
int |
inflate(byte[] b)
Uncompresses bytes into specified buffer. |
int |
inflate(byte[] b,
int off,
int len)
Uncompresses bytes into specified buffer. |
boolean |
needsDictionary()
Returns true if a preset dictionary is needed for decompression. |
boolean |
needsInput()
Returns true if no data remains in the input buffer. |
void |
reset()
Resets inflater so that a new set of input data can be processed. |
void |
setDictionary(byte[] b)
Sets the preset dictionary to the given array of bytes. |
void |
setDictionary(byte[] b,
int off,
int len)
Sets the preset dictionary to the given array of bytes. |
void |
setInput(byte[] b)
Sets input data for decompression. |
void |
setInput(byte[] b,
int off,
int len)
Sets input data for decompression. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Inflater(boolean nowrap)
Note: When using the 'nowrap' option it is also necessary to provide an extra "dummy" byte as input. This is required by the ZLIB native library in order to support certain optimizations.
nowrap - if true then support GZIP compatible compressionpublic Inflater()
| Method Detail |
|---|
public void setInput(byte[] b,
int off,
int len)
b - the input data bytesoff - the start offset of the input datalen - the length of the input dataneedsInput()public void setInput(byte[] b)
b - the input data bytesneedsInput()
public void setDictionary(byte[] b,
int off,
int len)
b - the dictionary data bytesoff - the start offset of the datalen - the length of the dataneedsDictionary(),
getAdler()public void setDictionary(byte[] b)
b - the dictionary data bytesneedsDictionary(),
getAdler()public int getRemaining()
public boolean needsInput()
public boolean needsDictionary()
setDictionary(byte[], int, int)public boolean finished()
public int inflate(byte[] b,
int off,
int len)
throws DataFormatException
b - the buffer for the uncompressed dataoff - the start offset of the datalen - the maximum number of uncompressed bytes
DataFormatException - if the compressed data format is invalidneedsInput(),
needsDictionary()
public int inflate(byte[] b)
throws DataFormatException
b - the buffer for the uncompressed data
DataFormatException - if the compressed data format is invalidneedsInput(),
needsDictionary()public int getAdler()
public int getTotalIn()
Since the number of bytes may be greater than
Integer.MAX_VALUE, the getBytesRead() method is now
the preferred means of obtaining this information.
public long getBytesRead()
public int getTotalOut()
Since the number of bytes may be greater than
Integer.MAX_VALUE, the getBytesWritten() method is now
the preferred means of obtaining this information.
public long getBytesWritten()
public void reset()
public void end()
protected void finalize()
Ces informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
7 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)