com.jguild.jrpm.io.cpio
public final class CPIOInputStream extends FilterInputStream implements CPIOConstants
CPIOInputStream cpioIn = new CPIOInputStream(new BufferedInputStream(
new FileInputStream(new File("test.cpio"))));
CPIOEntry cpioEntry;
while ((cpioEntry = cpioIn.getNextEntry()) != null) {
System.out.println(cpioEntry.getName());
int tmp;
StringBuffer buf = new StringBuffer();
while ((tmp = cpIn.read()) != -1) {
buf.append((char) tmp);
}
System.out.println(buf.toString());
}
cpioIn.close();
Note: This implementation should be compatible to cpio 2.5
Constructor Summary | |
---|---|
CPIOInputStream(InputStream in)
Construct the cpio input stream
|
Method Summary | |
---|---|
int | available()
Returns 0 after EOF has reached for the current entry data, otherwise
always return 1.
|
void | close()
Closes the CPIO input stream.
|
void | closeEntry()
Closes the current CPIO entry and positions the stream for reading the
next entry.
|
CPIOEntry | getNextEntry()
Reads the next CPIO file entry and positions stream at the beginning of
the entry data.
|
int | read()
Reads a byte of data. |
int | read(byte[] b, int off, int len)
Reads from the current CPIO entry into an array of bytes. |
long | skip(long n)
Skips specified number of bytes in the current CPIO entry.
|
Parameters: in The cpio stream
Returns: 1 before EOF and 0 after EOF has reached for current entry.
Throws: IOException if an I/O error has occurred or if a CPIO file error has occurred
Throws: IOException if an I/O error has occurred
Throws: IOException if an I/O error has occurred or if a CPIO file error has occurred
Returns: the CPIOEntry just read
Throws: IOException if an I/O error has occurred or if a CPIO file error has occurred
Returns: the byte read, or -1 if end of input is reached
Throws: IOException if an I/O error has occurred or if a CPIO file error has occurred
Parameters: b the buffer into which the data is read off the start offset of the data len the maximum number of bytes read
Returns: the actual number of bytes read, or -1 if the end of the entry is reached
Throws: IOException if an I/O error has occurred or if a CPIO file error has occurred
Parameters: n the number of bytes to skip
Returns: the actual number of bytes skipped
Throws: IOException if an I/O error has occurred IllegalArgumentException if n < 0