FileDocCategorySizeDatePackage
SocketOutputStream.javaAPI DocAndroid 1.5 API2430Wed May 06 22:41:04 BST 2009org.apache.harmony.luni.net

SocketOutputStream

public class SocketOutputStream extends OutputStream

Fields Summary
private PlainSocketImpl
socket
Constructors Summary
public SocketOutputStream(SocketImpl socket)
Constructs a SocketOutputStream for the socket. Write operations are forwarded to the socket.

param
socket the socket to be written
see
Socket

        super();
        this.socket = (PlainSocketImpl) socket;
    
Methods Summary
public voidclose()

        socket.close();
    
public voidwrite(byte[] buffer)

        socket.write(buffer, 0, buffer.length);
    
public voidwrite(byte[] buffer, int offset, int count)

        // avoid int overflow
        if (buffer != null) {
            if (0 <= offset && offset <= buffer.length && 0 <= count
                    && count <= buffer.length - offset) {
                socket.write(buffer, offset, count);
            } else {
                throw new ArrayIndexOutOfBoundsException(Msg.getString("K002f"));//$NON-NLS-1$
            }
        } else {
            throw new NullPointerException(Msg.getString("K0047"));//$NON-NLS-1$
        }
    
public voidwrite(int oneByte)

        byte[] buffer = new byte[1];
        buffer[0] = (byte) (oneByte & 0xFF);

        socket.write(buffer, 0, 1);