Java 类sun.misc.IoTrace 实例源码

项目:jdk-1.7-annotated    文件:SocketOutputStream.java   
/**
 * 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.
 */
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 {
        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 {
        impl.releaseFD();
        IoTrace.socketWriteEnd(traceContext, impl.address, impl.port, bytesWritten);
    }
}
项目:jdk-1.7-annotated    文件:FileInputStream.java   
/**
 * Reads a byte of data from this input stream. This method blocks
 * if no input is yet available.
 *
 * @return     the next byte of data, or <code>-1</code> if the end of the
 *             file is reached.
 * @exception  IOException  if an I/O error occurs.
 */
public int read() throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int b = 0;
    try {
        b = read0();
    } finally {
        IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
    }
    return b;
}
项目:jdk-1.7-annotated    文件:RandomAccessFile.java   
/**
 * Reads a sub array as a sequence of bytes.
 * @param b the buffer into which the data is read.
 * @param off the start offset of the data.
 * @param len the number of bytes to read.
 * @exception IOException If an I/O error has occurred.
 */
private int readBytes(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes0(b, off, len);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:jdk-1.7-annotated    文件:RandomAccessFile.java   
/**
 * Writes the specified byte to this file. The write starts at
 * the current file pointer.
 *
 * @param      b   the <code>byte</code> to be written.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(int b) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        write0(b);
        bytesWritten = 1;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:jdk-1.7-annotated    文件:RandomAccessFile.java   
/**
 * Writes a sub array as a sequence of bytes.
 * @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.
 */
private void writeBytes(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes0(b, off, len);
        bytesWritten = len;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:jdk-1.7-annotated    文件:FileOutputStream.java   
/**
 * Writes the specified byte to this file output stream. Implements
 * the <code>write</code> method of <code>OutputStream</code>.
 *
 * @param      b   the byte to be written.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(int b) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        write(b, append);
        bytesWritten = 1;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:jdk-1.7-annotated    文件:FileOutputStream.java   
/**
 * Writes <code>b.length</code> bytes from the specified byte array
 * to this file output stream.
 *
 * @param      b   the data.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(byte b[]) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes(b, 0, b.length, append);
        bytesWritten = b.length;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:jdk-1.7-annotated    文件:FileOutputStream.java   
/**
 * Writes <code>len</code> bytes from the specified byte array
 * starting at offset <code>off</code> to this file output stream.
 *
 * @param      b     the data.
 * @param      off   the start offset in the data.
 * @param      len   the number of bytes to write.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes(b, off, len, append);
        bytesWritten = len;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-jdk7u-jdk    文件:SocketOutputStream.java   
/**
 * 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.
 */
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 {
        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 {
        impl.releaseFD();
        IoTrace.socketWriteEnd(traceContext, impl.address, impl.port, bytesWritten);
    }
}
项目:openjdk-jdk7u-jdk    文件:FileInputStream.java   
/**
 * Reads a byte of data from this input stream. This method blocks
 * if no input is yet available.
 *
 * @return     the next byte of data, or <code>-1</code> if the end of the
 *             file is reached.
 * @exception  IOException  if an I/O error occurs.
 */
public int read() throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int b = 0;
    try {
        b = read0();
    } finally {
        IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
    }
    return b;
}
项目:openjdk-jdk7u-jdk    文件:RandomAccessFile.java   
/**
 * Reads a sub array as a sequence of bytes.
 * @param b the buffer into which the data is read.
 * @param off the start offset of the data.
 * @param len the number of bytes to read.
 * @exception IOException If an I/O error has occurred.
 */
private int readBytes(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes0(b, off, len);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:openjdk-jdk7u-jdk    文件:RandomAccessFile.java   
/**
 * Writes the specified byte to this file. The write starts at
 * the current file pointer.
 *
 * @param      b   the <code>byte</code> to be written.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(int b) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        write0(b);
        bytesWritten = 1;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-jdk7u-jdk    文件:RandomAccessFile.java   
/**
 * Writes a sub array as a sequence of bytes.
 * @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.
 */
private void writeBytes(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes0(b, off, len);
        bytesWritten = len;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-jdk7u-jdk    文件:FileOutputStream.java   
/**
 * Writes the specified byte to this file output stream. Implements
 * the <code>write</code> method of <code>OutputStream</code>.
 *
 * @param      b   the byte to be written.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(int b) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        write(b, append);
        bytesWritten = 1;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-jdk7u-jdk    文件:FileOutputStream.java   
/**
 * Writes <code>b.length</code> bytes from the specified byte array
 * to this file output stream.
 *
 * @param      b   the data.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(byte b[]) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes(b, 0, b.length, append);
        bytesWritten = b.length;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-jdk7u-jdk    文件:FileOutputStream.java   
/**
 * Writes <code>len</code> bytes from the specified byte array
 * starting at offset <code>off</code> to this file output stream.
 *
 * @param      b     the data.
 * @param      off   the start offset in the data.
 * @param      len   the number of bytes to write.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes(b, off, len, append);
        bytesWritten = len;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-icedtea7    文件:SocketOutputStream.java   
/**
 * 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.
 */
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 {
        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 {
        impl.releaseFD();
        IoTrace.socketWriteEnd(traceContext, impl.address, impl.port, bytesWritten);
    }
}
项目:openjdk-icedtea7    文件:FileInputStream.java   
/**
 * Reads a byte of data from this input stream. This method blocks
 * if no input is yet available.
 *
 * @return     the next byte of data, or <code>-1</code> if the end of the
 *             file is reached.
 * @exception  IOException  if an I/O error occurs.
 */
public int read() throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int b = 0;
    try {
        b = read0();
    } finally {
        IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
    }
    return b;
}
项目:openjdk-icedtea7    文件:RandomAccessFile.java   
/**
 * Reads a sub array as a sequence of bytes.
 * @param b the buffer into which the data is read.
 * @param off the start offset of the data.
 * @param len the number of bytes to read.
 * @exception IOException If an I/O error has occurred.
 */
private int readBytes(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes0(b, off, len);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:openjdk-icedtea7    文件:RandomAccessFile.java   
/**
 * Writes the specified byte to this file. The write starts at
 * the current file pointer.
 *
 * @param      b   the <code>byte</code> to be written.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(int b) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        write0(b);
        bytesWritten = 1;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-icedtea7    文件:RandomAccessFile.java   
/**
 * Writes a sub array as a sequence of bytes.
 * @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.
 */
private void writeBytes(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes0(b, off, len);
        bytesWritten = len;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-icedtea7    文件:FileOutputStream.java   
/**
 * Writes the specified byte to this file output stream. Implements
 * the <code>write</code> method of <code>OutputStream</code>.
 *
 * @param      b   the byte to be written.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(int b) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        write(b, append);
        bytesWritten = 1;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-icedtea7    文件:FileOutputStream.java   
/**
 * Writes <code>b.length</code> bytes from the specified byte array
 * to this file output stream.
 *
 * @param      b   the data.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(byte b[]) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes(b, 0, b.length, append);
        bytesWritten = b.length;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-icedtea7    文件:FileOutputStream.java   
/**
 * Writes <code>len</code> bytes from the specified byte array
 * starting at offset <code>off</code> to this file output stream.
 *
 * @param      b     the data.
 * @param      off   the start offset in the data.
 * @param      len   the number of bytes to write.
 * @exception  IOException  if an I/O error occurs.
 */
public void write(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileWriteBegin(path);
    int bytesWritten = 0;
    try {
        writeBytes(b, off, len, append);
        bytesWritten = len;
    } finally {
        IoTrace.fileWriteEnd(traceContext, bytesWritten);
    }
}
项目:openjdk-jdk7u-jdk    文件:SocketAdaptor.java   
protected int read(ByteBuffer bb)
    throws IOException
{
    synchronized (sc.blockingLock()) {
        if (!sc.isBlocking())
            throw new IllegalBlockingModeException();
        if (timeout == 0)
            return sc.read(bb);

        // Implement timeout with a selector
        SelectionKey sk = null;
        Selector sel = null;
        sc.configureBlocking(false);
        int n = 0;
        Object traceContext = IoTrace.socketReadBegin();
        try {
            if ((n = sc.read(bb)) != 0)
                return n;
            sel = Util.getTemporarySelector(sc);
            sk = sc.register(sel, SelectionKey.OP_READ);
            long to = timeout;
            for (;;) {
                if (!sc.isOpen())
                    throw new ClosedChannelException();
                long st = System.currentTimeMillis();
                int ns = sel.select(to);
                if (ns > 0 && sk.isReadable()) {
                    if ((n = sc.read(bb)) != 0)
                        return n;
                }
                sel.selectedKeys().remove(sk);
                to -= System.currentTimeMillis() - st;
                if (to <= 0)
                    throw new SocketTimeoutException();
            }
        } finally {
            IoTrace.socketReadEnd(traceContext, getInetAddress(),
                                  getPort(), timeout, n > 0 ? n : 0);
            if (sk != null)
                sk.cancel();
            if (sc.isOpen())
                sc.configureBlocking(true);
            if (sel != null)
                Util.releaseTemporarySelector(sel);
        }

    }
}
项目:openjdk-jdk7u-jdk    文件:IoTraceAgent.java   
public static void premain(String agentArgs, Instrumentation inst)
        throws Exception {
    ClassDefinition cd = new ClassDefinition(IoTrace.class,
            generateClassAsm());
    inst.redefineClasses(cd);
}
项目:openjdk-icedtea7    文件:SocketAdaptor.java   
protected int read(ByteBuffer bb)
    throws IOException
{
    synchronized (sc.blockingLock()) {
        if (!sc.isBlocking())
            throw new IllegalBlockingModeException();
        if (timeout == 0)
            return sc.read(bb);

        // Implement timeout with a selector
        SelectionKey sk = null;
        Selector sel = null;
        sc.configureBlocking(false);
        int n = 0;
        Object traceContext = IoTrace.socketReadBegin();
        try {
            if ((n = sc.read(bb)) != 0)
                return n;
            sel = Util.getTemporarySelector(sc);
            sk = sc.register(sel, SelectionKey.OP_READ);
            long to = timeout;
            for (;;) {
                if (!sc.isOpen())
                    throw new ClosedChannelException();
                long st = System.currentTimeMillis();
                int ns = sel.select(to);
                if (ns > 0 && sk.isReadable()) {
                    if ((n = sc.read(bb)) != 0)
                        return n;
                }
                sel.selectedKeys().remove(sk);
                to -= System.currentTimeMillis() - st;
                if (to <= 0)
                    throw new SocketTimeoutException();
            }
        } finally {
            IoTrace.socketReadEnd(traceContext, getInetAddress(),
                                  getPort(), timeout, n > 0 ? n : 0);
            if (sk != null)
                sk.cancel();
            if (sc.isOpen())
                sc.configureBlocking(true);
            if (sel != null)
                Util.releaseTemporarySelector(sel);
        }

    }
}
项目:openjdk-icedtea7    文件:IoTraceAgent.java   
public static void premain(String agentArgs, Instrumentation inst)
        throws Exception {
    ClassDefinition cd = new ClassDefinition(IoTrace.class,
            generateClassAsm());
    inst.redefineClasses(cd);
}
项目:jdk-1.7-annotated    文件:FileInputStream.java   
/**
 * Reads up to <code>b.length</code> bytes of data from this input
 * stream into an array of bytes. This method blocks until some input
 * is available.
 *
 * @param      b   the buffer into which the data is read.
 * @return     the total number of bytes read into the buffer, or
 *             <code>-1</code> if there is no more data because the end of
 *             the file has been reached.
 * @exception  IOException  if an I/O error occurs.
 */
public int read(byte b[]) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes(b, 0, b.length);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:jdk-1.7-annotated    文件:FileInputStream.java   
/**
 * Reads up to <code>len</code> bytes of data from this input stream
 * into an array of bytes. If <code>len</code> is not zero, the method
 * blocks until some input is available; otherwise, no
 * bytes are read and <code>0</code> is returned.
 *
 * @param      b     the buffer into which the data is read.
 * @param      off   the start offset in the destination array <code>b</code>
 * @param      len   the maximum number of bytes read.
 * @return     the total number of bytes read into the buffer, or
 *             <code>-1</code> if there is no more data because the end of
 *             the file has been reached.
 * @exception  NullPointerException If <code>b</code> is <code>null</code>.
 * @exception  IndexOutOfBoundsException If <code>off</code> is negative,
 * <code>len</code> is negative, or <code>len</code> is greater than
 * <code>b.length - off</code>
 * @exception  IOException  if an I/O error occurs.
 */
public int read(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes(b, off, len);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:jdk-1.7-annotated    文件:RandomAccessFile.java   
/**
 * Reads a byte of data from this file. The byte is returned as an
 * integer in the range 0 to 255 (<code>0x00-0x0ff</code>). This
 * method blocks if no input is yet available.
 * <p>
 * Although <code>RandomAccessFile</code> is not a subclass of
 * <code>InputStream</code>, this method behaves in exactly the same
 * way as the {@link InputStream#read()} method of
 * <code>InputStream</code>.
 *
 * @return     the next byte of data, or <code>-1</code> if the end of the
 *             file has been reached.
 * @exception  IOException  if an I/O error occurs. Not thrown if
 *                          end-of-file has been reached.
 */
public int read() throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int b = 0;
    try {
        b = read0();
    } finally {
        IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
    }
    return b;
}
项目:openjdk-jdk7u-jdk    文件:FileInputStream.java   
/**
 * Reads up to <code>b.length</code> bytes of data from this input
 * stream into an array of bytes. This method blocks until some input
 * is available.
 *
 * @param      b   the buffer into which the data is read.
 * @return     the total number of bytes read into the buffer, or
 *             <code>-1</code> if there is no more data because the end of
 *             the file has been reached.
 * @exception  IOException  if an I/O error occurs.
 */
public int read(byte b[]) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes(b, 0, b.length);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:openjdk-jdk7u-jdk    文件:FileInputStream.java   
/**
 * Reads up to <code>len</code> bytes of data from this input stream
 * into an array of bytes. If <code>len</code> is not zero, the method
 * blocks until some input is available; otherwise, no
 * bytes are read and <code>0</code> is returned.
 *
 * @param      b     the buffer into which the data is read.
 * @param      off   the start offset in the destination array <code>b</code>
 * @param      len   the maximum number of bytes read.
 * @return     the total number of bytes read into the buffer, or
 *             <code>-1</code> if there is no more data because the end of
 *             the file has been reached.
 * @exception  NullPointerException If <code>b</code> is <code>null</code>.
 * @exception  IndexOutOfBoundsException If <code>off</code> is negative,
 * <code>len</code> is negative, or <code>len</code> is greater than
 * <code>b.length - off</code>
 * @exception  IOException  if an I/O error occurs.
 */
public int read(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes(b, off, len);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:openjdk-jdk7u-jdk    文件:RandomAccessFile.java   
/**
 * Reads a byte of data from this file. The byte is returned as an
 * integer in the range 0 to 255 (<code>0x00-0x0ff</code>). This
 * method blocks if no input is yet available.
 * <p>
 * Although <code>RandomAccessFile</code> is not a subclass of
 * <code>InputStream</code>, this method behaves in exactly the same
 * way as the {@link InputStream#read()} method of
 * <code>InputStream</code>.
 *
 * @return     the next byte of data, or <code>-1</code> if the end of the
 *             file has been reached.
 * @exception  IOException  if an I/O error occurs. Not thrown if
 *                          end-of-file has been reached.
 */
public int read() throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int b = 0;
    try {
        b = read0();
    } finally {
        IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
    }
    return b;
}
项目:openjdk-icedtea7    文件:FileInputStream.java   
/**
 * Reads up to <code>b.length</code> bytes of data from this input
 * stream into an array of bytes. This method blocks until some input
 * is available.
 *
 * @param      b   the buffer into which the data is read.
 * @return     the total number of bytes read into the buffer, or
 *             <code>-1</code> if there is no more data because the end of
 *             the file has been reached.
 * @exception  IOException  if an I/O error occurs.
 */
public int read(byte b[]) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes(b, 0, b.length);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:openjdk-icedtea7    文件:FileInputStream.java   
/**
 * Reads up to <code>len</code> bytes of data from this input stream
 * into an array of bytes. If <code>len</code> is not zero, the method
 * blocks until some input is available; otherwise, no
 * bytes are read and <code>0</code> is returned.
 *
 * @param      b     the buffer into which the data is read.
 * @param      off   the start offset in the destination array <code>b</code>
 * @param      len   the maximum number of bytes read.
 * @return     the total number of bytes read into the buffer, or
 *             <code>-1</code> if there is no more data because the end of
 *             the file has been reached.
 * @exception  NullPointerException If <code>b</code> is <code>null</code>.
 * @exception  IndexOutOfBoundsException If <code>off</code> is negative,
 * <code>len</code> is negative, or <code>len</code> is greater than
 * <code>b.length - off</code>
 * @exception  IOException  if an I/O error occurs.
 */
public int read(byte b[], int off, int len) throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int bytesRead = 0;
    try {
        bytesRead = readBytes(b, off, len);
    } finally {
        IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
    }
    return bytesRead;
}
项目:openjdk-icedtea7    文件:RandomAccessFile.java   
/**
 * Reads a byte of data from this file. The byte is returned as an
 * integer in the range 0 to 255 (<code>0x00-0x0ff</code>). This
 * method blocks if no input is yet available.
 * <p>
 * Although <code>RandomAccessFile</code> is not a subclass of
 * <code>InputStream</code>, this method behaves in exactly the same
 * way as the {@link InputStream#read()} method of
 * <code>InputStream</code>.
 *
 * @return     the next byte of data, or <code>-1</code> if the end of the
 *             file has been reached.
 * @exception  IOException  if an I/O error occurs. Not thrown if
 *                          end-of-file has been reached.
 */
public int read() throws IOException {
    Object traceContext = IoTrace.fileReadBegin(path);
    int b = 0;
    try {
        b = read0();
    } finally {
        IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
    }
    return b;
}