01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-2006, Geotools Project Managment Committee (PMC)
05: * (C) 2001, Institut de Recherche pour le Développement
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: */
17: package org.geotools.image.io;
18:
19: // Input/output
20: import java.io.IOException;
21: import java.io.OutputStream;
22: import javax.imageio.stream.ImageOutputStream;
23:
24: /**
25: * Wraps an {@link ImageOutputStream} into a standard {@link OutputStream}.
26: *
27: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/coverageio/src/main/java/org/geotools/image/io/OutputStreamAdapter.java $
28: * @version $Id: OutputStreamAdapter.java 25467 2007-05-08 16:30:30Z desruisseaux $
29: * @author Martin Desruisseaux
30: */
31: final class OutputStreamAdapter extends OutputStream {
32: /**
33: * The wrapped image output stream.
34: */
35: private final ImageOutputStream output;
36:
37: /**
38: * Construct a new output stream.
39: */
40: public OutputStreamAdapter(final ImageOutputStream output) {
41: this .output = output;
42: }
43:
44: /**
45: * Writes the specified byte to this output stream.
46: *
47: * @throws IOException if an I/O error occurs.
48: */
49: public void write(final int b) throws IOException {
50: output.write(b);
51: }
52:
53: /**
54: * Writes {@code b.length} bytes from the specified byte array.
55: *
56: * @throws IOException if an I/O error occurs.
57: */
58: public void write(final byte[] b) throws IOException {
59: output.write(b);
60: }
61:
62: /**
63: * Writes {@code len} bytes from the specified byte array.
64: *
65: * @throws IOException if an I/O error occurs.
66: */
67: public void write(final byte[] b, final int off, final int len)
68: throws IOException {
69: output.write(b, off, len);
70: }
71:
72: /**
73: * Forces any buffered output bytes to be written out.
74: *
75: * @throws IOException if an I/O error occurs.
76: */
77: public void flush() throws IOException {
78: output.flush();
79: }
80:
81: /**
82: * Closes this output stream.
83: *
84: * @throws IOException if an I/O error occurs.
85: */
86: public void close() throws IOException {
87: output.close();
88: }
89: }
|