- java.lang.Object
-
- java.io.InputStream
-
- java.io.ByteArrayInputStream
-
- javax.mail.util.SharedByteArrayInputStream
-
- All Implemented Interfaces:
- Closeable, AutoCloseable, SharedInputStream
public class SharedByteArrayInputStream extends ByteArrayInputStream implements SharedInputStream
A ByteArrayInputStream that implements the SharedInputStream interface, allowing the underlying byte array to be shared between multiple readers.- Since:
- JavaMail 1.4
- Author:
- Bill Shannon
-
-
Field Summary
Fields Modifier and Type Field and Description protected int
start
Position within shared buffer that this stream starts at.
-
Constructor Summary
Constructors Constructor and Description SharedByteArrayInputStream(byte[] buf)
Create a SharedByteArrayInputStream representing the entire byte array.SharedByteArrayInputStream(byte[] buf, int offset, int length)
Create a SharedByteArrayInputStream representing the part of the byte array fromoffset
forlength
bytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description long
getPosition()
Return the current position in the InputStream, as an offset from the beginning of the InputStream.InputStream
newStream(long start, long end)
Return a new InputStream representing a subset of the data from this InputStream, starting atstart
(inclusive) up toend
(exclusive).-
Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, read, read, reset, skip
-
Methods inherited from class java.io.InputStream
read
-
-
-
-
Constructor Detail
-
SharedByteArrayInputStream
public SharedByteArrayInputStream(byte[] buf)
Create a SharedByteArrayInputStream representing the entire byte array.- Parameters:
buf
- the byte array
-
SharedByteArrayInputStream
public SharedByteArrayInputStream(byte[] buf, int offset, int length)
Create a SharedByteArrayInputStream representing the part of the byte array fromoffset
forlength
bytes.- Parameters:
buf
- the byte arrayoffset
- offset in byte array to first byte to includelength
- number of bytes to include
-
-
Method Detail
-
getPosition
public long getPosition()
Return the current position in the InputStream, as an offset from the beginning of the InputStream.- Specified by:
getPosition
in interfaceSharedInputStream
- Returns:
- the current position
-
newStream
public InputStream newStream(long start, long end)
Return a new InputStream representing a subset of the data from this InputStream, starting atstart
(inclusive) up toend
(exclusive).start
must be non-negative. Ifend
is -1, the new stream ends at the same place as this stream. The returned InputStream will also implement the SharedInputStream interface.- Specified by:
newStream
in interfaceSharedInputStream
- Parameters:
start
- the starting positionend
- the ending position + 1- Returns:
- the new stream
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/08/2025 17:18:17 Cette version de la page est en cache (à la date du 21/08/2025 17:18:17) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 19/04/2008, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/mail/util/SharedByteArrayInputStream.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.