public PDSInputStream(PDS pds, String member) throws IOException { this.pds = pds; if (pds == null || pds.data == null) throw new IOException("PDS member " + member + " not found"); Object on = pds.directory.get(member); if (on == null) throw new IOException("PDS member " + member + " not found"); left = ((PDSEntry) on).len; savedPosition = pds.getFilePointer(); pds.seek((long) ((PDSEntry) on).loc); }
public int read(byte[] b, int off, int len) throws IOException { if (left <= 0) return -1; if (left < len) len = left; int n = pds.read(b, off, len); left -= n; return n; }
public int read() throws IOException { if (left <= 0) return -1; else { int c = pds.read(); left--; return c; } }
public void close() throws IOException { pds.seek(savedPosition); }