Hi
I suspect that there is an easy solution to this but I have not figured it out as of yet. The following procedure takes the contents of MESSAGE (a static byte[]) and reads it into the InputStream, where it will then be appended to some message headers, then signed and encrypted. This works fine for any MESSAGE less than or equal to 8192 bytes.
Any thoughts on how I can read beyond 8192 bytes ... the message that I want read is about 30,000 bytes and rarely would I need to go beyond this. So as you can see we are not dealing with large files here.
public int read(byte[] b, int offset, int length) throws IOException
{
if (b == null)
{
throw new NullPointerException();
}
else if (
(offset < 0)
|| (offset > b.length)
|| (length < 0)
|| ((offset + length) > b.length)
|| ((offset + length) < 0))
{
throw new IndexOutOfBoundsException();
}
else if (m_readCount >= MAX_READ_COUNT)
{
return -1;
}
else if (length == 0)
{
return 0;
}
if (m_readCount >= MAX_READ_COUNT)
{
return -1;
}
else
{
int bytesToCopy = Math.min(MESSAGE.length, length);
System.arraycopy(MESSAGE, 0, b, offset, bytesToCopy);
++m_readCount;
return bytesToCopy;
}
}
}