java.lang.Objectjava.io.OutputStream
java.io.ByteArrayOutputStream
public class ByteArrayOutputStream
This class implements an output stream in which the data is
written into a byte array. The buffer automatically grows as data
is written to it.
The data can be retrieved using toByteArray() and
toString().
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
| Field Summary | |
|---|---|
protected byte[] |
buf
The buffer where data is stored. |
protected int |
count
The number of valid bytes in the buffer. |
| Constructor Summary | |
|---|---|
ByteArrayOutputStream()
Creates a new byte array output stream. |
|
ByteArrayOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes. |
|
| Method Summary | |
|---|---|
void |
close()
Closing a ByteArrayOutputStream has no effect. |
void |
reset()
Resets the count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. |
int |
size()
Returns the current size of the buffer. |
byte[] |
toByteArray()
Creates a newly allocated byte array. |
String |
toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding. |
String |
toString(int hibyte)
Deprecated. This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the toString(String enc) method, which takes an encoding-name
argument, or the toString() method, which uses the
platform's default character encoding. |
String |
toString(String enc)
Converts the buffer's contents into a string, translating bytes into characters according to the specified character encoding. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this byte array output stream. |
void |
write(int b)
Writes the specified byte to this byte array output stream. |
void |
writeTo(OutputStream out)
Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count). |
| Methods inherited from class java.io.OutputStream |
|---|
flush, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected byte[] buf
protected int count
| Constructor Detail |
|---|
public ByteArrayOutputStream()
public ByteArrayOutputStream(int size)
size - the initial size.
IllegalArgumentException - if size is negative.| Method Detail |
|---|
public void write(int b)
write in class OutputStreamb - the byte to be written.
public void write(byte[] b,
int off,
int len)
len bytes from the specified byte array
starting at offset off to this byte array output stream.
write in class OutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.public void writeTo(OutputStream out) throws IOException
out.write(buf, 0, count).
out - the output stream to which to write the data.
IOException - if an I/O error occurs.public void reset()
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. The output stream can be used again,
reusing the already allocated buffer space.
ByteArrayInputStream.countpublic byte[] toByteArray()
size()public int size()
count field, which is the number
of valid bytes in this output stream.countpublic String toString()
public String toString(String enc) throws UnsupportedEncodingException
enc - a character-encoding name.
UnsupportedEncodingException - If the named encoding is not supported.@Deprecated public String toString(int hibyte)
toString(String enc) method, which takes an encoding-name
argument, or the toString() method, which uses the
platform's default character encoding.
c == (char)(((hibyte & 0xff) << 8) | (b & 0xff))
hibyte - the high byte of each resulting Unicode character.
size(),
toString(String),
toString()
public void close()
throws IOException
close in interface Closeableclose in class OutputStreamIOException - if an I/O error occurs.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.
6 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)