Methods Summary |
---|
public void | close()
// Prevent recursion. See BugId 4484411
if (closing)
return;
closing = true;
if (socket != null) {
if (!socket.isClosed())
socket.close();
} else
impl.close();
closing = false;
|
protected void | finalize()Overrides finalize, the fd is closed by the Socket.
|
public final java.nio.channels.FileChannel | getChannel()Returns the unique {@link java.nio.channels.FileChannel FileChannel}
object associated with this file output stream.
The getChannel method of SocketOutputStream
returns null since it is a socket based stream.
return null;
|
private static native void | init()Perform class load-time initializations.
|
private void | socketWrite(byte[] b, int off, int len)Writes to the socket with appropriate locking of the
FileDescriptor.
if (len <= 0 || off < 0 || off + len > b.length) {
if (len == 0) {
return;
}
throw new ArrayIndexOutOfBoundsException();
}
FileDescriptor fd = impl.acquireFD();
try {
socketWrite0(fd, b, off, len);
} catch (SocketException se) {
if (se instanceof sun.net.ConnectionResetException) {
impl.setConnectionResetPending();
se = new SocketException("Connection reset");
}
if (impl.isClosedOrPending()) {
throw new SocketException("Socket closed");
} else {
throw se;
}
} finally {
impl.releaseFD();
}
|
private native void | socketWrite0(java.io.FileDescriptor fd, byte[] b, int off, int len)Writes to the socket.
|
public void | write(int b)Writes a byte to the socket.
temp[0] = (byte)b;
socketWrite(temp, 0, 1);
|
public void | write(byte[] b)Writes the contents of the buffer b to the socket.
socketWrite(b, 0, b.length);
|
public void | write(byte[] b, int off, int len)Writes length bytes from buffer b starting at
offset len.
socketWrite(b, off, len);
|