File tree Expand file tree Collapse file tree
io/src/main/java/org/apache/pdfbox/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 */
1717package org .apache .pdfbox .io ;
1818
19+ import java .io .EOFException ;
1920import java .io .IOException ;
2021import java .io .InputStream ;
2122
@@ -164,6 +165,23 @@ else if (!fetch())
164165 return numberOfBytesRead ;
165166 }
166167
168+ @ Override
169+ public void readFully (byte [] b , int offset , int length ) throws IOException
170+ {
171+ // override the default implementation as the return value from length isn't reliable
172+ checkClosed ();
173+ int bytesReadTotal = 0 ;
174+ while (bytesReadTotal < length )
175+ {
176+ int bytesReadNow = read (b , offset + bytesReadTotal , length - bytesReadTotal );
177+ if (bytesReadNow <= 0 )
178+ {
179+ throw new EOFException ("EOF, should have been detected earlier" );
180+ }
181+ bytesReadTotal += bytesReadNow ;
182+ }
183+ }
184+
167185 private void switchBuffers (int firstBuffer , int secondBuffer )
168186 {
169187 byte [] tmpBuffer = buffers [firstBuffer ];
@@ -222,6 +240,16 @@ private boolean fetch() throws IOException
222240 return true ;
223241 }
224242
243+ /**
244+ * Returns an estimate of the number of bytes that can be read (or skipped over) from the underlying input stream
245+ * without blocking, which may be 0, or 0 when end of stream is detected.
246+ */
247+ @ Override
248+ public int available () throws IOException
249+ {
250+ checkClosed ();
251+ return is .available ();
252+ }
225253
226254 /**
227255 * {@inheritDoc}
You can’t perform that action at this time.
0 commit comments