|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.FilterOutputStream com.jguild.jrpm.io.cpio.CPIOOutputStream
CPIOOutputStream is a stream for writting cpio streams. All formats of cpio are supported (old ascii, old binary, new portable format and the new portable format with crc).
An entry can be written by creating an instance of CPIOEntry and fill it with the necessary values and put it into the cpio stream. Afterwards write the contents of the file into the cpio stream. Either close the stream by calling finish() or put a next entry into the cpio stream.
Note: This implementation should be compatible to cpio 2.5
CPIOOutputStream cpioOut = new CPIOOutputStream(new BufferedOutputStream(new FileOutputStream(new File("test.cpio"))));
CPIOEntry cpioEntry = new CPIOEntry();
cpioEntry.setName("testfile");
String testContents = "12345";
cpioEntry.setFileSize(testContents.length());
cpioOut.putNextEntry(cpioEntry);
cpioOut.write(testContents.getBytes());
cpioOut.finish();
cpioOut.close();
Field Summary |
Fields inherited from class java.io.FilterOutputStream |
out |
Fields inherited from interface com.jguild.jrpm.io.cpio.CPIOConstants |
C_IRGRP, C_IROTH, C_IRUSR, C_ISBLK, C_ISCHR, C_ISDIR, C_ISFIFO, C_ISGID, C_ISLNK, C_ISNWK, C_ISREG, C_ISSOCK, C_ISUID, C_ISVTX, C_IWGRP, C_IWOTH, C_IWUSR, C_IXGRP, C_IXOTH, C_IXUSR, FORMAT_NEW, FORMAT_NEW_CRC, FORMAT_NEW_MASK, FORMAT_OLD_ASCII, FORMAT_OLD_BINARY, FORMAT_OLD_MASK, MAGIC_NEW, MAGIC_NEW_CRC, MAGIC_OLD_ASCII, MAGIC_OLD_BINARY, S_IFMT |
Constructor Summary | |
CPIOOutputStream(java.io.OutputStream out)
Construct the cpio output stream. |
|
CPIOOutputStream(java.io.OutputStream out,
short format)
Construct the cpio output stream with a specified format |
Method Summary | |
void |
close()
Closes the CPIO output stream as well as the stream being filtered. |
void |
closeEntry()
Closes the current CPIO entry and positions the stream for writing the next entry. |
void |
finish()
Finishes writing the contents of the CPIO output stream without closing the underlying stream. |
void |
putNextEntry(CPIOEntry e)
Begins writing a new CPIO file entry and positions the stream to the start of the entry data. |
void |
setFormat(short format)
Set a default header format. |
void |
write(byte[] b,
int off,
int len)
Writes an array of bytes to the current CPIO entry data. |
Methods inherited from class java.io.FilterOutputStream |
flush, write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CPIOOutputStream(java.io.OutputStream out, short format)
out
- The cpio streamformat
- The format of the streampublic CPIOOutputStream(java.io.OutputStream out)
out
- The cpio streamMethod Detail |
public void setFormat(short format)
format
- A CPIO formatpublic void putNextEntry(CPIOEntry e) throws java.io.IOException
e
- the CPIO cpioEntry to be written
java.io.IOException
- if an I/O error has occurred or
if a CPIO file error has occurredpublic void closeEntry() throws java.io.IOException
java.io.IOException
- if an I/O error has occurred or
if a CPIO file error has occurredpublic void write(byte[] b, int off, int len) throws java.io.IOException
b
- the data to be writtenoff
- the start offset in the datalen
- the number of bytes that are written
java.io.IOException
- if an I/O error has occurred or
if a CPIO file error has occurredpublic void finish() throws java.io.IOException
java.io.IOException
- if an I/O exception has occurred or
if a CPIO file error has occurredpublic void close() throws java.io.IOException
java.io.IOException
- if an I/O error has occurred or
if a CPIO file error has occurred
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |