23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong> I/O<br />

pairs, one to a line. Names are separated from values by colons and whitespace, as in email<br />

headers. For example:<br />

Name: com/macfaq/awt/Filmstrip.class<br />

<strong>Java</strong>-Bean: true<br />

Last-modified: 09-07-1998<br />

Depends-On: com/macfaq/io/StreamCopier.class<br />

Brad: Majors<br />

Digest-Algorithms: MD5<br />

MD5-Digest: XD4578YEEIK9MGX54RFGT7UJUI9810<br />

This defines an entry with the name com/macfaq/awt/Filmstrip.class. This entry has six<br />

attributes: <strong>Java</strong>-Bean with the value true, Last-modified with the value 09-07-1998, Brad<br />

with the value Majors, Depends-On with the value com/macfaq/io/StreamCopier.class,<br />

and so on. Each of these has a specific meaning in a particular context. For instance, the<br />

<strong>Java</strong>-Bean attribute with the value true means that this class is a <strong>Java</strong> Bean that can be<br />

loaded into a visual builder tool. Digest-Algorithms gives you the types of message digests<br />

computed from the file, and MD5-Digest gives the value of one particular digest. Most of the<br />

attributes have an application-specific meaning. Applications reading a JAR archive that don't<br />

understand a particular attribute should simply ignore it.<br />

One possible manifest file for the directory shown in Figure 9.3 looks like this:<br />

Manifest-Version: 1.0<br />

Name: com/macfaq/awt/StreamedTextArea.class<br />

Name: com/macfaq/io/BufferedStreamCopier.class<br />

Name: com/macfaq/io/FileCopier.class<br />

Name: com/macfaq/io/LittleEndianOutputStream.class<br />

Name: com/macfaq/io/MultiOutputStream.class<br />

Name: com/macfaq/io/NullOutputStream.class<br />

Name: com/macfaq/io/PrintableInputStream.class<br />

Name: com/macfaq/io/PrintableOutputStream.class<br />

Name: com/macfaq/io/RandomInputStream.class<br />

Name: com/macfaq/io/StreamCopier.class<br />

Brad: Majors<br />

Name: com/macfaq/io/TeeOutputStream.class<br />

Riff: Raff<br />

Name: com/macfaq/util/CommandLineArguments.class<br />

The files in the JAR archive may be signed using a digital signature algorithm. Different<br />

individuals may sign different files, and more than one person may sign each file. For each<br />

file that's signed, the META-INF directory will also contain a signature file. I won't discuss<br />

signatures in great detail here; for starters, they're very different in <strong>Java</strong> 1.1 and <strong>Java</strong> 2.<br />

However, you should realize that signatures can be checked when a file is read from a JAR<br />

178

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!