Source Code Cross Referenced for FilterInputStream.java in  » Apache-Harmony-Java-SE » java-package » 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 » Apache Harmony Java SE » java package » java.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package java.io;
019:
020:        /**
021:         * FilteredInputStream is a class which takes an input stream and
022:         * <em>filters</em> the input in some way. The filtered view may be a buffered
023:         * view or one which uncompresses data before returning bytes read.
024:         * FilterInputStreams are meant for byte streams.
025:         * 
026:         * @see FilterOutputStream
027:         */
028:        public class FilterInputStream extends InputStream {
029:
030:            /**
031:             * The target InputStream which is being filtered.
032:             */
033:            protected InputStream in;
034:
035:            /**
036:             * Constructs a new FilterInputStream on the InputStream <code>in</code>.
037:             * All reads are now filtered through this stream.
038:             * 
039:             * @param in
040:             *            The non-null InputStream to filter reads on.
041:             */
042:            protected FilterInputStream(InputStream in) {
043:                super ();
044:                this .in = in;
045:            }
046:
047:            /**
048:             * Answers a int representing the number of bytes that are available before
049:             * this FilterInputStream will block. This method returns the number of
050:             * bytes available in the target stream.
051:             * 
052:             * @return the number of bytes available before blocking.
053:             * 
054:             * @throws IOException
055:             *             If an error occurs in this stream.
056:             */
057:            @Override
058:            public int available() throws IOException {
059:                return in.available();
060:            }
061:
062:            /**
063:             * Close this FilterInputStream. This implementation closes the target
064:             * stream.
065:             * 
066:             * @throws IOException
067:             *             If an error occurs attempting to close this stream.
068:             */
069:            @Override
070:            public void close() throws IOException {
071:                in.close();
072:            }
073:
074:            /**
075:             * Set a Mark position in this FilterInputStream. The parameter
076:             * <code>readLimit</code> indicates how many bytes can be read before a
077:             * mark is invalidated. Sending reset() will reposition the Stream back to
078:             * the marked position provided <code>readLimit</code> has not been
079:             * surpassed.
080:             * <p>
081:             * This implementation sets a mark in the target stream.
082:             * 
083:             * @param readlimit
084:             *            the number of bytes to be able to read before invalidating the
085:             *            mark.
086:             */
087:            @Override
088:            public synchronized void mark(int readlimit) {
089:                in.mark(readlimit);
090:            }
091:
092:            /**
093:             * Answers a boolean indicating whether or not this FilterInputStream
094:             * supports mark() and reset(). This implementation answers whether or not
095:             * the target stream supports marking.
096:             * 
097:             * @return <code>true</code> if mark() and reset() are supported,
098:             *         <code>false</code> otherwise.
099:             */
100:            @Override
101:            public boolean markSupported() {
102:                return in.markSupported();
103:            }
104:
105:            /**
106:             * Reads a single byte from this FilterInputStream and returns the result as
107:             * an int. The low-order byte is returned or -1 of the end of stream was
108:             * encountered. This implementation returns a byte from the target stream.
109:             * 
110:             * @return the byte read or -1 if end of stream.
111:             * 
112:             * @throws IOException
113:             *             If the stream is already closed or another IOException
114:             *             occurs.
115:             */
116:            @Override
117:            public int read() throws IOException {
118:                return in.read();
119:            }
120:
121:            /**
122:             * Reads bytes from this FilterInputStream and stores them in byte array
123:             * <code>buffer</code>. Answer the number of bytes actually read or -1 if
124:             * no bytes were read and end of stream was encountered. This implementation
125:             * reads bytes from the target stream.
126:             * 
127:             * @param buffer
128:             *            the byte array in which to store the read bytes.
129:             * @return the number of bytes actually read or -1 if end of stream.
130:             * 
131:             * @throws IOException
132:             *             If the stream is already closed or another IOException
133:             *             occurs.
134:             */
135:            @Override
136:            public int read(byte[] buffer) throws IOException {
137:                return read(buffer, 0, buffer.length);
138:            }
139:
140:            /**
141:             * Reads at most <code>count</code> bytes from this FilterInputStream and
142:             * stores them in byte array <code>buffer</code> starting at
143:             * <code>offset</code>. Answer the number of bytes actually read or -1 if
144:             * no bytes were read and end of stream was encountered. This implementation
145:             * reads bytes from the target stream.
146:             * 
147:             * @param buffer
148:             *            the byte array in which to store the read bytes.
149:             * @param offset
150:             *            the offset in <code>buffer</code> to store the read bytes.
151:             * @param count
152:             *            the maximum number of bytes to store in <code>buffer</code>.
153:             * @return the number of bytes actually read or -1 if end of stream.
154:             * 
155:             * @throws IOException
156:             *             If the stream is already closed or another IOException
157:             *             occurs.
158:             */
159:            @Override
160:            public int read(byte[] buffer, int offset, int count)
161:                    throws IOException {
162:                return in.read(buffer, offset, count);
163:            }
164:
165:            /**
166:             * Reset this FilterInputStream to the last marked location. If the
167:             * <code>readlimit</code> has been passed or no <code>mark</code> has
168:             * been set, throw IOException. This implementation resets the target
169:             * stream.
170:             * 
171:             * @throws IOException
172:             *             If the stream is already closed or another IOException
173:             *             occurs.
174:             */
175:            @Override
176:            public synchronized void reset() throws IOException {
177:                in.reset();
178:            }
179:
180:            /**
181:             * Skips <code>count</code> number of bytes in this InputStream.
182:             * Subsequent <code>read()</code>'s will not return these bytes unless
183:             * <code>reset()</code> is used. This implementation skips
184:             * <code>count</code> number of bytes in the target stream.
185:             * 
186:             * @param count
187:             *            the number of bytes to skip.
188:             * @return the number of bytes actually skipped.
189:             * 
190:             * @throws IOException
191:             *             If the stream is already closed or another IOException
192:             *             occurs.
193:             */
194:            @Override
195:            public long skip(long count) throws IOException {
196:                return in.skip(count);
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.