Writes to the socket with appropriate locking of the
FileDescriptor.
@param b the data to be written
@param off the start offset in the data
@param len the number of bytes that are written
@exception IOException If an I/O error has occurred.
7244
private void socketWrite(byte b[], int off, int len) throws IOException {

        if (len <= 0 || off < 0 || off + len > b.length) {
            if (len == 0) {
                return;
            }
            throw new ArrayIndexOutOfBoundsException();
        }

        Object traceContext = IoTrace.socketWriteBegin();
        int bytesWritten = 0;
        FileDescriptor fd = impl.acquireFD();
        try {
            BlockGuard.getThreadPolicy().onNetwork();
            socketWrite0(fd, b, off, len);
            bytesWritten = 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 {
            IoTrace.socketWriteEnd(traceContext, impl.address, impl.port, bytesWritten);
        }
    }
1124483
@Override
  public void write(byte[] b, int offset, int len) throws IOException {
    long startTime = System.nanoTime();
    out.write(b, offset, len);
    statistics.incrementBytesWritten(len);
    long duration = System.nanoTime() - startTime;
    ghfs.increment(GoogleHadoopFileSystemBase.Counter.WRITE);
    ghfs.increment(GoogleHadoopFileSystemBase.Counter.WRITE_TIME, duration);
  }
997781
@Override
    public void write ( byte[] b, int off, int len ) throws IOException {
        writeDirect(b, off, len, 0);
    }
740743
public void write(byte[] b, int off, int len) throws IOException
	{
		if (b == null)
			throw new NullPointerException();
		if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length)
			|| ((off + len) < 0))
			throw new IndexOutOfBoundsException();
		p.writeBytes(b, off, len);
	}
1195813
public void write(byte[] b, int off, int len) throws IOException {
        out.write(b, off, len);
        cksum.update(b, off, len);
    }
1072747
public void write(int b) {
        int newcount = count + 1;
        if (newcount > buffer.length) buffer = copyOf(buffer, Math.max(buffer.length << 1, newcount));
        buffer[count] = (byte) b;
        count = newcount;
    }
1315383
public void write (byte[] buf, int off, int len)
            throws IOException
     {
            out.write (buf, off, len);
     }
195009
public void write(char buf[], int off, int len) {
        try {
            synchronized (lock) {
                ensureOpen();
                out.write(buf, off, len);
            }
        }
        catch (InterruptedIOException x) {
            Thread.currentThread().interrupt();
        }
        catch (IOException x) {
            trouble = true;
        }
    }
483939
public void write(final byte[] src, int off, int len)
	{
		if(src == null) throw new NullPointerException();
		if((off < 0) || (off > src.length) || (len < 0) || ((off + len) > src.length) || ((off + len) < 0)) throw new IndexOutOfBoundsException();

		writeLoop(src, off, len);		
	}
151425
public void write(String s, int off, int len) throws IOException {
        // defect 312981 begin
        //ensureOpen();
    	if (closed) {
    	    throw new IOException("Stream closed");
        }
        // defect 312981 end
        if (bufferSize == 0) {
            initOut();
            out.write(s, off, len);
            return;
        }
        int b = off, t = off + len;
        while (b < t) {
            int d = min(bufferSize - nextChar, t - b);
            s.getChars(b, b + d, cb, nextChar);
            b += d;
            nextChar += d;
            if (nextChar >= bufferSize) 
                if (autoFlush)
                    flushBuffer();
                else
                    bufferOverflow();
        }
    }
505928
@Override
  public void write(byte[] b, int off, int len) {
    write(new String(b, off, len));
  }
1243990
@Override
  public void write(byte[] b, int off, int len) throws IOException {
    textArea.append(new String(b, off, len));
  }
89980
@Override
	public synchronized void write(byte[] b, int off, int len)
			throws IOException {
		consolidateSoftCopy();
		alertSoftCopies();
		super.write(b, off, len);
	}
1341366
public void write(byte[] buf, int off, int len) throws IOException {
    // This could of course be optimized
    for (int i = 0; i < len; i++) {
      write(buf[off + i]);
    }
  }
275173
@Override
    public void write(byte[] b, int off, int len) throws IOException {
        while (len > 0) {
            int c = Math.min(len, decoderIn.remaining());
            decoderIn.put(b, off, c);
            processInput(false);
            len -= c;
            off += c;
        }
        if (writeImmediately) {
            flushOutput();
        }
    }
27179
@Override
    public void write(byte[] b, int byteOffset, int byteLength)
            throws IOException
    {
        if (closed) {
            throw new IOException("Stream is closed");
        }
        int cursor = 0;
        while (cursor < byteLength) {
            int readLen = Math.min(byteLength - cursor, blockSize - inputCursor);
            // copy the input data to uncompressed buffer
            if (readLen > 0) {
                System.arraycopy(b, byteOffset + cursor, inputBuffer, inputCursor, readLen);
                inputCursor += readLen;
            }
            if (inputCursor < blockSize) {
                return;
            }

            compressInput();
            cursor += readLen;
        }
    }
1320546
protected synchronized void write(int b) throws IOException {
		if (closed) {
			throw new IOException("The buffer is closed");
		}

		verifyBufferSize(1);
		buf[writepos] = (byte) b;
		writepos++;

		notifyAll();
	}