Source Code Cross Referenced for FilterOutputStream.java in  » 6.0-JDK-Modules » j2me » java » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » java.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)FilterOutputStream.java	1.35 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.  
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER  
006:         *   
007:         * This program is free software; you can redistribute it and/or  
008:         * modify it under the terms of the GNU General Public License version  
009:         * 2 only, as published by the Free Software Foundation.   
010:         *   
011:         * This program is distributed in the hope that it will be useful, but  
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of  
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  
014:         * General Public License version 2 for more details (a copy is  
015:         * included at /legal/license.txt).   
016:         *   
017:         * You should have received a copy of the GNU General Public License  
018:         * version 2 along with this work; if not, write to the Free Software  
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
020:         * 02110-1301 USA   
021:         *   
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa  
023:         * Clara, CA 95054 or visit www.sun.com if you need additional  
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package java.io;
029:
030:        /**
031:         * This class is the superclass of all classes that filter output 
032:         * streams. These streams sit on top of an already existing output 
033:         * stream (the <i>underlying</i> output stream) which it uses as its 
034:         * basic sink of data, but possibly transforming the data along the 
035:         * way or providing additional functionality. 
036:         * <p>
037:         * The class <code>FilterOutputStream</code> itself simply overrides 
038:         * all methods of <code>OutputStream</code> with versions that pass 
039:         * all requests to the underlying output stream. Subclasses of 
040:         * <code>FilterOutputStream</code> may further override some of these 
041:         * methods as well as provide additional methods and fields. 
042:         *
043:         * @author  Jonathan Payne
044:         * @version 1.28, 02/02/00
045:         * @since   JDK1.0
046:         */
047:        public class FilterOutputStream extends OutputStream {
048:            /**
049:             * The underlying output stream to be filtered. 
050:             */
051:            protected OutputStream out;
052:
053:            /**
054:             * Creates an output stream filter built on top of the specified 
055:             * underlying output stream. 
056:             *
057:             * @param   out   the underlying output stream to be assigned to 
058:             *                the field <tt>this.out</tt> for later use, or 
059:             *                <code>null</code> if this instance is to be 
060:             *                created without an underlying stream.
061:             */
062:            public FilterOutputStream(OutputStream out) {
063:                this .out = out;
064:            }
065:
066:            /**
067:             * Writes the specified <code>byte</code> to this output stream. 
068:             * <p>
069:             * The <code>write</code> method of <code>FilterOutputStream</code> 
070:             * calls the <code>write</code> method of its underlying output stream, 
071:             * that is, it performs <tt>out.write(b)</tt>.
072:             * <p>
073:             * Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>. 
074:             *
075:             * @param      b   the <code>byte</code>.
076:             * @exception  IOException  if an I/O error occurs.
077:             */
078:            public void write(int b) throws IOException {
079:                out.write(b);
080:            }
081:
082:            /**
083:             * Writes <code>b.length</code> bytes to this output stream. 
084:             * <p>
085:             * The <code>write</code> method of <code>FilterOutputStream</code> 
086:             * calls its <code>write</code> method of three arguments with the 
087:             * arguments <code>b</code>, <code>0</code>, and 
088:             * <code>b.length</code>. 
089:             * <p>
090:             * Note that this method does not call the one-argument 
091:             * <code>write</code> method of its underlying stream with the single 
092:             * argument <code>b</code>. 
093:             *
094:             * @param      b   the data to be written.
095:             * @exception  IOException  if an I/O error occurs.
096:             * @see        java.io.FilterOutputStream#write(byte[], int, int)
097:             */
098:            public void write(byte b[]) throws IOException {
099:                write(b, 0, b.length);
100:            }
101:
102:            /**
103:             * Writes <code>len</code> bytes from the specified 
104:             * <code>byte</code> array starting at offset <code>off</code> to 
105:             * this output stream. 
106:             * <p>
107:             * The <code>write</code> method of <code>FilterOutputStream</code> 
108:             * calls the <code>write</code> method of one argument on each 
109:             * <code>byte</code> to output. 
110:             * <p>
111:             * Note that this method does not call the <code>write</code> method 
112:             * of its underlying input stream with the same arguments. Subclasses 
113:             * of <code>FilterOutputStream</code> should provide a more efficient 
114:             * implementation of this method. 
115:             *
116:             * @param      b     the data.
117:             * @param      off   the start offset in the data.
118:             * @param      len   the number of bytes to write.
119:             * @exception  IOException  if an I/O error occurs.
120:             * @see        java.io.FilterOutputStream#write(int)
121:             */
122:            public void write(byte b[], int off, int len) throws IOException {
123:                if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
124:                    throw new IndexOutOfBoundsException();
125:
126:                for (int i = 0; i < len; i++) {
127:                    write(b[off + i]);
128:                }
129:            }
130:
131:            /**
132:             * Flushes this output stream and forces any buffered output bytes 
133:             * to be written out to the stream. 
134:             * <p>
135:             * The <code>flush</code> method of <code>FilterOutputStream</code> 
136:             * calls the <code>flush</code> method of its underlying output stream. 
137:             *
138:             * @exception  IOException  if an I/O error occurs.
139:             * @see        java.io.FilterOutputStream#out
140:             */
141:            public void flush() throws IOException {
142:                out.flush();
143:            }
144:
145:            /**
146:             * Closes this output stream and releases any system resources 
147:             * associated with the stream. 
148:             * <p>
149:             * The <code>close</code> method of <code>FilterOutputStream</code> 
150:             * calls its <code>flush</code> method, and then calls the 
151:             * <code>close</code> method of its underlying output stream. 
152:             *
153:             * @exception  IOException  if an I/O error occurs.
154:             * @see        java.io.FilterOutputStream#flush()
155:             * @see        java.io.FilterOutputStream#out
156:             */
157:            public void close() throws IOException {
158:                try {
159:                    flush();
160:                } catch (IOException ignored) {
161:                }
162:                out.close();
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.