FileDocCategorySizeDatePackage
ByteArray.javaAPI DocJavaMail 1.4.33780Tue Nov 17 10:38:10 GMT 2009com.sun.mail.iap

ByteArray

public class ByteArray extends Object
A simple wrapper around a byte array, with a start position and count of bytes.
author
John Mani

Fields Summary
private byte[]
bytes
private int
start
private int
count
Constructors Summary
public ByteArray(byte[] b, int start, int count)
Constructor

	bytes = b;
	this.start = start;
	this.count = count;
    
public ByteArray(int size)
Constructor that creates a byte array of the specified size.

since
JavaMail 1.4.1

	this(new byte[size], 0, size);
    
Methods Summary
public byte[]getBytes()
Returns the internal byte array. Note that this is a live reference to the actual data, not a copy.

	return bytes;
    
public intgetCount()
Returns the count of bytes

	return count;
    
public byte[]getNewBytes()
Returns a new byte array that is a copy of the data.

	byte[] b = new byte[count];
	System.arraycopy(bytes, start, b, 0, count);
	return b;
    
public intgetStart()
Returns the start position

	return start;
    
public voidgrow(int incr)
Grow the byte array by incr bytes.

since
JavaMail 1.4.1

	byte[] nbuf = new byte[bytes.length + incr];
	System.arraycopy(bytes, 0, nbuf, 0, bytes.length);
	bytes = nbuf;
    
public voidsetCount(int count)
Set the count of bytes.

since
JavaMail 1.4.1

	this.count = count;
    
public java.io.ByteArrayInputStreamtoByteArrayInputStream()
Returns a ByteArrayInputStream.

	return new ByteArrayInputStream(bytes, start, count);