/** * Reads an array of strings from the TIFF file. * * @param count Number of strings to read * @param value Offset from which to read */ protected String[] readASCIIArray(long count, long value) throws IOException { _raf.seek(value); int nstrs = 0; List list = new LinkedList(); byte[] buf = new byte[(int) count]; _raf.read(buf); StringBuffer strbuf = new StringBuffer(); for (int i = 0; i < count; i++) { int b = buf[i]; if (b == 0) { list.add(strbuf.toString()); strbuf.setLength(0); } else { strbuf.append((char) b); } } /* We can't use ArrayList.toArray because that returns an Object[], not a String[] ... sigh. */ String[] strs = new String[nstrs]; ListIterator iter = list.listIterator(); for (int i = 0; i < nstrs; i++) { strs[i] = (String) iter.next(); } return strs; }