java.net
Class SocketOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FileOutputStream
              |
              +--java.net.SocketOutputStream

class SocketOutputStream
extends FileOutputStream

This stream extends FileOutputStream to implement a SocketOutputStream. Note that this class should NOT be public.

Version:
1.27, 04/23/02
Author:
Jonathan Payne, Arthur van Hoff

Field Summary
private  boolean closing
          Closes the stream.
private  PlainSocketImpl impl
           
private  Socket socket
           
private  byte[] temp
           
 
Fields inherited from class java.io.FileOutputStream
 
Constructor Summary
(package private) SocketOutputStream(PlainSocketImpl impl)
          Creates a new SocketOutputStream.
 
Method Summary
 void close()
          Enabled: Closes this file output stream and releases any system resources associated with this stream.
protected  void finalize()
          Overrides finalize, the fd is closed by the Socket.
 java.nio.channels.FileChannel getChannel()
          Returns the unique FileChannel object associated with this file output stream.
private static 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.
private  void socketWrite0(FileDescriptor fd, byte[] b, int off, int len)
          Writes to the socket.
 void write(byte[] b)
          Writes the contents of the buffer b to the socket.
 void write(byte[] b, int off, int len)
          Writes length bytes from buffer b starting at offset len.
 void write(int b)
          Writes a byte to the socket.
 
Methods inherited from class java.io.FileOutputStream
getFD
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

impl

private PlainSocketImpl impl

temp

private byte[] temp

socket

private Socket socket

closing

private boolean closing
Closes the stream.

Constructor Detail

SocketOutputStream

SocketOutputStream(PlainSocketImpl impl)
             throws IOException
Creates a new SocketOutputStream. Can only be called by a Socket. This method needs to hang on to the owner Socket so that the fd will not be closed.

Parameters:
impl - the socket output stream inplemented
Method Detail

getChannel

public final java.nio.channels.FileChannel getChannel()
Returns the unique FileChannel object associated with this file output stream.

The getChannel method of SocketOutputStream returns null since it is a socket based stream.

Overrides:
getChannel in class FileOutputStream
Returns:
the file channel associated with this file output stream
Since:
1.4

socketWrite0

private void socketWrite0(FileDescriptor fd,
                          byte[] b,
                          int off,
                          int len)
                   throws IOException
Writes to the socket.

Parameters:
fd - the FileDescriptor
b - the data to be written
off - the start offset in the data
len - the number of bytes that are written
IOException

socketWrite

private void socketWrite(byte[] b,
                         int off,
                         int len)
                  throws IOException
Writes to the socket with appropriate locking of the FileDescriptor.

Parameters:
b - the data to be written
off - the start offset in the data
len - the number of bytes that are written
IOException

write

public void write(int b)
           throws IOException
Writes a byte to the socket.

Overrides:
write in class FileOutputStream
Parameters:
b - the data to be written
IOException

write

public void write(byte[] b)
           throws IOException
Writes the contents of the buffer b to the socket.

Overrides:
write in class FileOutputStream
Parameters:
b - the data to be written
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes length bytes from buffer b starting at offset len.

Overrides:
write in class FileOutputStream
Parameters:
b - the data to be written
off - the start offset in the data
len - the number of bytes that are written
IOException

close

public void close()
           throws IOException
Description copied from class: FileOutputStream
Enabled: Closes this file output stream and releases any system resources associated with this stream. This file output stream may no longer be used for writing bytes.

If this stream has an associated channel then the channel is closed as well.

Overrides:
close in class FileOutputStream
IOException

finalize

protected void finalize()
Overrides finalize, the fd is closed by the Socket.

Overrides:
finalize in class FileOutputStream
See Also:
java.io.FileInputStream#close()

init

private static void init()
Perform class load-time initializations.



comments?