Source Code Cross Referenced for OutputStream.java in  » 6.0-JDK-Core » io-nio » java » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » io nio » java.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1994-2004 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.io;
027
028        /**
029         * This abstract class is the superclass of all classes representing 
030         * an output stream of bytes. An output stream accepts output bytes 
031         * and sends them to some sink.
032         * <p>
033         * Applications that need to define a subclass of 
034         * <code>OutputStream</code> must always provide at least a method 
035         * that writes one byte of output.
036         *
037         * @author  Arthur van Hoff
038         * @version 1.36, 05/05/07
039         * @see     java.io.BufferedOutputStream
040         * @see     java.io.ByteArrayOutputStream
041         * @see     java.io.DataOutputStream
042         * @see     java.io.FilterOutputStream
043         * @see     java.io.InputStream
044         * @see     java.io.OutputStream#write(int)
045         * @since   JDK1.0
046         */
047        public abstract class OutputStream implements  Closeable, Flushable {
048            /**
049             * Writes the specified byte to this output stream. The general 
050             * contract for <code>write</code> is that one byte is written 
051             * to the output stream. The byte to be written is the eight 
052             * low-order bits of the argument <code>b</code>. The 24 
053             * high-order bits of <code>b</code> are ignored.
054             * <p>
055             * Subclasses of <code>OutputStream</code> must provide an 
056             * implementation for this method. 
057             *
058             * @param      b   the <code>byte</code>.
059             * @exception  IOException  if an I/O error occurs. In particular, 
060             *             an <code>IOException</code> may be thrown if the 
061             *             output stream has been closed.
062             */
063            public abstract void write(int b) throws IOException;
064
065            /**
066             * Writes <code>b.length</code> bytes from the specified byte array 
067             * to this output stream. The general contract for <code>write(b)</code> 
068             * is that it should have exactly the same effect as the call 
069             * <code>write(b, 0, b.length)</code>.
070             *
071             * @param      b   the data.
072             * @exception  IOException  if an I/O error occurs.
073             * @see        java.io.OutputStream#write(byte[], int, int)
074             */
075            public void write(byte b[]) throws IOException {
076                write(b, 0, b.length);
077            }
078
079            /**
080             * Writes <code>len</code> bytes from the specified byte array 
081             * starting at offset <code>off</code> to this output stream. 
082             * The general contract for <code>write(b, off, len)</code> is that 
083             * some of the bytes in the array <code>b</code> are written to the 
084             * output stream in order; element <code>b[off]</code> is the first 
085             * byte written and <code>b[off+len-1]</code> is the last byte written 
086             * by this operation.
087             * <p>
088             * The <code>write</code> method of <code>OutputStream</code> calls 
089             * the write method of one argument on each of the bytes to be 
090             * written out. Subclasses are encouraged to override this method and 
091             * provide a more efficient implementation. 
092             * <p>
093             * If <code>b</code> is <code>null</code>, a 
094             * <code>NullPointerException</code> is thrown.
095             * <p>
096             * If <code>off</code> is negative, or <code>len</code> is negative, or 
097             * <code>off+len</code> is greater than the length of the array 
098             * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown.
099             *
100             * @param      b     the data.
101             * @param      off   the start offset in the data.
102             * @param      len   the number of bytes to write.
103             * @exception  IOException  if an I/O error occurs. In particular, 
104             *             an <code>IOException</code> is thrown if the output 
105             *             stream is closed.
106             */
107            public void write(byte b[], int off, int len) throws IOException {
108                if (b == null) {
109                    throw new NullPointerException();
110                } else if ((off < 0) || (off > b.length) || (len < 0)
111                        || ((off + len) > b.length) || ((off + len) < 0)) {
112                    throw new IndexOutOfBoundsException();
113                } else if (len == 0) {
114                    return;
115                }
116                for (int i = 0; i < len; i++) {
117                    write(b[off + i]);
118                }
119            }
120
121            /**
122             * Flushes this output stream and forces any buffered output bytes 
123             * to be written out. The general contract of <code>flush</code> is 
124             * that calling it is an indication that, if any bytes previously 
125             * written have been buffered by the implementation of the output 
126             * stream, such bytes should immediately be written to their 
127             * intended destination.
128             * <p>
129             * If the intended destination of this stream is an abstraction provided by
130             * the underlying operating system, for example a file, then flushing the
131             * stream guarantees only that bytes previously written to the stream are
132             * passed to the operating system for writing; it does not guarantee that
133             * they are actually written to a physical device such as a disk drive.
134             * <p>
135             * The <code>flush</code> method of <code>OutputStream</code> does nothing.
136             *
137             * @exception  IOException  if an I/O error occurs.
138             */
139            public void flush() throws IOException {
140            }
141
142            /**
143             * Closes this output stream and releases any system resources 
144             * associated with this stream. The general contract of <code>close</code> 
145             * is that it closes the output stream. A closed stream cannot perform 
146             * output operations and cannot be reopened.
147             * <p>
148             * The <code>close</code> method of <code>OutputStream</code> does nothing.
149             *
150             * @exception  IOException  if an I/O error occurs.
151             */
152            public void close() throws IOException {
153            }
154
155        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.