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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

}<br />

StreamCopier.copy(in, out);<br />

in.close();<br />

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

The main() method is responsible for choosing the file and format to be dumped. The dump()<br />

method translates an input stream onto an output stream using a particular filter. This allows<br />

the dump() method to be used by other classes as a more general translation service for<br />

streams. An alternative pattern would pass the filter as an argument to dump() rather than an<br />

integer mode. This might make the program more flexible but would not allow you to easily<br />

chain several filters together as we'll do in upcoming chapters.<br />

95

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

Saved successfully!

Ooh no, something went wrong!