[
https://issues.apache.org/jira/browse/PDFBOX-6083?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18029191#comment-18029191
]
Tilman Hausherr commented on PDFBOX-6083:
-----------------------------------------
{code:java}
/**
* Same as {@link #read(byte[], int, int)} but will loop until exactly
length bytes are read or
* it will throw an exception.
*
* @param b The buffer to write the data to.
* @param offset Offset into the buffer to start writing.
* @param length The exact amount of data to attempt to read.
* @throws IOException
*/
default void readFully(byte[] b, int offset, int length) throws IOException
{
int bytesReadTotal = 0;
do
{
int bytesReadNow = read(b, offset + bytesReadTotal, length -
bytesReadTotal);
if (bytesReadNow < 0)
{
throw new EOFException("EOF");
}
bytesReadTotal += bytesReadNow;
}
while (bytesReadTotal < length);
}
{code}
> optimize DataInputRandomAccessRead
> ----------------------------------
>
> Key: PDFBOX-6083
> URL: https://issues.apache.org/jira/browse/PDFBOX-6083
> Project: PDFBox
> Issue Type: Improvement
> Components: FontBox, IO
> Affects Versions: 3.0.6 PDFBox
> Reporter: Tilman Hausherr
> Priority: Minor
>
> To optimize DataInputRandomAccessRead.readBytes() we need a
> RandomAccessRead.readFully() method.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]