OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / luni / src / main / java / java / io / ObjectOutput.java
1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17
18 package java.io;
19
20 /**
21  * Defines an interface for classes that allow reading serialized objects.
22  *
23  * @see ObjectOutputStream
24  * @see ObjectInput
25  */
26 public interface ObjectOutput extends DataOutput {
27     /**
28      * Closes the target stream. Implementations of this method should free any
29      * resources used by the stream.
30      *
31      * @throws IOException
32      *             if an error occurs while closing the target stream.
33      */
34     public void close() throws IOException;
35
36     /**
37      * Flushes the target stream. Implementations of this method should ensure
38      * that any pending writes are written out to the target stream.
39      *
40      * @throws IOException
41      *             if an error occurs while flushing the target stream.
42      */
43     public void flush() throws IOException;
44
45     /**
46      * Writes the entire contents of the byte array {@code buffer} to the output
47      * stream. Blocks until all bytes are written.
48      *
49      * @param buffer
50      *            the buffer to write.
51      * @throws IOException
52      *             if an error occurs while writing to the target stream.
53      */
54     public void write(byte[] buffer) throws IOException;
55
56     /**
57      * Writes {@code count} bytes from the byte array {@code buffer} starting at
58      * position {@code offset} to the target stream. Blocks until all bytes are
59      * written.
60      *
61      * @param buffer
62      *            the buffer to write.
63      * @param offset
64      *            the index of the first byte in {@code buffer} to write.
65      * @param count
66      *            the number of bytes from {@code buffer} to write to the target
67      *            stream.
68      * @throws IOException
69      *             if an error occurs while writing to the target stream.
70      */
71     public void write(byte[] buffer, int offset, int count) throws IOException;
72
73     /**
74      * Writes a single byte to the target stream. Only the least significant
75      * byte of the integer {@code value} is written to the stream. Blocks until
76      * the byte is actually written.
77      *
78      * @param value
79      *            the byte to write.
80      * @throws IOException
81      *             if an error occurs while writing to the target stream.
82      */
83     public void write(int value) throws IOException;
84
85     /**
86      * Writes the specified object {@code obj} to the target stream.
87      *
88      * @param obj
89      *            the object to write.
90      * @throws IOException
91      *             if an error occurs while writing to the target stream.
92      */
93     public void writeObject(Object obj) throws IOException;
94 }