/** * Reads an array. When this is called, we have already read the ArrayStart token, and arrayDepth * has been incremented to reflect this. */ public PdfArray readArray() throws IOException, PdfException { PdfArray arr = new PdfArray(); for (; ; ) { PdfObject obj = null; try { obj = readObject(); arr.add(obj); } // We detect the end of an array by a PdfException being thrown // when readObject encounters the close bracket. When we get // the end of the array, collapse the vector before returning the object. catch (PdfException e) { Token tok = e.getToken(); if (tok instanceof ArrayEnd) { collapseObjectVector(arr.getContent()); return arr; } else { throw e; // real error } } } }