java.nio.ByteBuffer.checkWritable()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中java.nio.ByteBuffer.checkWritable()方法的一些代码示例,展示了ByteBuffer.checkWritable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.checkWritable()方法的具体详情如下:
包路径:java.nio.ByteBuffer
类名称:ByteBuffer
方法名:checkWritable

ByteBuffer.checkWritable介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * @param copyingIn true if we're copying data into the buffers (typically
 * because the caller is a file/network read operation), false if we're
 * copying data out of the buffers (for a file/network write operation).
 */
static int calculateTotalRemaining(ByteBuffer[] buffers, int offset, int length, boolean copyingIn) {
  int count = 0;
  for (int i = offset; i < offset + length; ++i) {
    count += buffers[i].remaining();
    if (copyingIn) {
      buffers[i].checkWritable();
    }
  }
  return count;
}

代码示例来源:origin: robovm/robovm

@Override
public int read(ByteBuffer dst) throws IOException {
  dst.checkWritable();
  checkOpenConnected();
  if (!dst.hasRemaining()) {
    return 0;
  }
  return readImpl(dst);
}

代码示例来源:origin: robovm/robovm

int init() {
  int totalRemaining = 0;
  for (int i = 0; i < bufferCount; ++i) {
    ByteBuffer b = byteBuffers[i + offset];
    if (direction == Direction.READV) {
      b.checkWritable();
    }
    int remaining = b.remaining();
    if (b.isDirect()) {
      ioBuffers[i] = b;
      offsets[i] = b.position();
    } else {
      ioBuffers[i] = NioUtils.unsafeArray(b);
      offsets[i] = NioUtils.unsafeArrayOffset(b) + b.position();
    }
    byteCounts[i] = remaining;
    totalRemaining += remaining;
  }
  return totalRemaining;
}

代码示例来源:origin: robovm/robovm

@Override
public int read(ByteBuffer target) throws IOException {
  target.checkWritable();
  checkOpenConnected();
  if (!target.hasRemaining()) {
    return 0;
  }
  int readCount = 0;
  if (target.isDirect() || target.hasArray()) {
    readCount = readImpl(target);
    if (readCount > 0) {
      target.position(target.position() + readCount);
    }
  } else {
    byte[] readArray = new byte[target.remaining()];
    ByteBuffer readBuffer = ByteBuffer.wrap(readArray);
    readCount = readImpl(readBuffer);
    if (readCount > 0) {
      target.put(readArray, 0, readCount);
    }
  }
  return readCount;
}

代码示例来源:origin: robovm/robovm

private int readImpl(ByteBuffer buffer, long position) throws IOException {
  buffer.checkWritable();
  checkOpen();
  checkReadable();

代码示例来源:origin: robovm/robovm

@Override
public SocketAddress receive(ByteBuffer target) throws IOException {
  target.checkWritable();
  checkOpen();
  if (!isBound) {
    return null;
  }
  SocketAddress retAddr = null;
  try {
    begin();
    // receive real data packet, (not peek)
    synchronized (readLock) {
      boolean loop = isBlocking();
      if (!target.isDirect()) {
        retAddr = receiveImpl(target, loop);
      } else {
        retAddr = receiveDirectImpl(target, loop);
      }
    }
  } catch (InterruptedIOException e) {
    // this line used in Linux
    return null;
  } finally {
    end(retAddr != null);
  }
  return retAddr;
}

代码示例来源:origin: ibinti/bugvm

/**
 * @param copyingIn true if we're copying data into the buffers (typically
 * because the caller is a file/network read operation), false if we're
 * copying data out of the buffers (for a file/network write operation).
 */
static int calculateTotalRemaining(ByteBuffer[] buffers, int offset, int length, boolean copyingIn) {
  int count = 0;
  for (int i = offset; i < offset + length; ++i) {
    count += buffers[i].remaining();
    if (copyingIn) {
      buffers[i].checkWritable();
    }
  }
  return count;
}

代码示例来源:origin: MobiVM/robovm

/**
 * @param copyingIn true if we're copying data into the buffers (typically
 * because the caller is a file/network read operation), false if we're
 * copying data out of the buffers (for a file/network write operation).
 */
static int calculateTotalRemaining(ByteBuffer[] buffers, int offset, int length, boolean copyingIn) {
  int count = 0;
  for (int i = offset; i < offset + length; ++i) {
    count += buffers[i].remaining();
    if (copyingIn) {
      buffers[i].checkWritable();
    }
  }
  return count;
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * @param copyingIn true if we're copying data into the buffers (typically
 * because the caller is a file/network read operation), false if we're
 * copying data out of the buffers (for a file/network write operation).
 */
static int calculateTotalRemaining(ByteBuffer[] buffers, int offset, int length, boolean copyingIn) {
  int count = 0;
  for (int i = offset; i < offset + length; ++i) {
    count += buffers[i].remaining();
    if (copyingIn) {
      buffers[i].checkWritable();
    }
  }
  return count;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * @param copyingIn true if we're copying data into the buffers (typically
 * because the caller is a file/network read operation), false if we're
 * copying data out of the buffers (for a file/network write operation).
 */
static int calculateTotalRemaining(ByteBuffer[] buffers, int offset, int length, boolean copyingIn) {
  int count = 0;
  for (int i = offset; i < offset + length; ++i) {
    count += buffers[i].remaining();
    if (copyingIn) {
      buffers[i].checkWritable();
    }
  }
  return count;
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * @param copyingIn true if we're copying data into the buffers (typically
 * because the caller is a file/network read operation), false if we're
 * copying data out of the buffers (for a file/network write operation).
 */
static int calculateTotalRemaining(ByteBuffer[] buffers, int offset, int length, boolean copyingIn) {
  int count = 0;
  for (int i = offset; i < offset + length; ++i) {
    count += buffers[i].remaining();
    if (copyingIn) {
      buffers[i].checkWritable();
    }
  }
  return count;
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * @param copyingIn true if we're copying data into the buffers (typically
 * because the caller is a file/network read operation), false if we're
 * copying data out of the buffers (for a file/network write operation).
 */
static int calculateTotalRemaining(ByteBuffer[] buffers, int offset, int length, boolean copyingIn) {
  int count = 0;
  for (int i = offset; i < offset + length; ++i) {
    count += buffers[i].remaining();
    if (copyingIn) {
      buffers[i].checkWritable();
    }
  }
  return count;
}

代码示例来源:origin: MobiVM/robovm

@Override
public int read(ByteBuffer dst) throws IOException {
  dst.checkWritable();
  checkOpenConnected();
  if (!dst.hasRemaining()) {
    return 0;
  }
  return readImpl(dst);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

@Override
public int read(ByteBuffer dst) throws IOException {
  dst.checkWritable();
  checkOpenConnected();
  if (!dst.hasRemaining()) {
    return 0;
  }
  return readImpl(dst);
}

代码示例来源:origin: com.gluonhq/robovm-rt

@Override
public int read(ByteBuffer dst) throws IOException {
  dst.checkWritable();
  checkOpenConnected();
  if (!dst.hasRemaining()) {
    return 0;
  }
  return readImpl(dst);
}

代码示例来源:origin: ibinti/bugvm

@Override
public int read(ByteBuffer dst) throws IOException {
  dst.checkWritable();
  checkOpenConnected();
  if (!dst.hasRemaining()) {
    return 0;
  }
  return readImpl(dst);
}

代码示例来源:origin: FlexoVM/flexovm

@Override
public int read(ByteBuffer dst) throws IOException {
  dst.checkWritable();
  checkOpenConnected();
  if (!dst.hasRemaining()) {
    return 0;
  }
  return readImpl(dst);
}

代码示例来源:origin: com.bugvm/bugvm-rt

@Override
public int read(ByteBuffer dst) throws IOException {
  dst.checkWritable();
  checkOpenConnected();
  if (!dst.hasRemaining()) {
    return 0;
  }
  return readImpl(dst);
}

代码示例来源:origin: MobiVM/robovm

int init() {
  int totalRemaining = 0;
  for (int i = 0; i < bufferCount; ++i) {
    ByteBuffer b = byteBuffers[i + offset];
    if (direction == Direction.READV) {
      b.checkWritable();
    }
    int remaining = b.remaining();
    if (b.isDirect()) {
      ioBuffers[i] = b;
      offsets[i] = b.position();
    } else {
      ioBuffers[i] = NioUtils.unsafeArray(b);
      offsets[i] = NioUtils.unsafeArrayOffset(b) + b.position();
    }
    byteCounts[i] = remaining;
    totalRemaining += remaining;
  }
  return totalRemaining;
}

代码示例来源:origin: ibinti/bugvm

int init() {
  int totalRemaining = 0;
  for (int i = 0; i < bufferCount; ++i) {
    ByteBuffer b = byteBuffers[i + offset];
    if (direction == Direction.READV) {
      b.checkWritable();
    }
    int remaining = b.remaining();
    if (b.isDirect()) {
      ioBuffers[i] = b;
      offsets[i] = b.position();
    } else {
      ioBuffers[i] = NioUtils.unsafeArray(b);
      offsets[i] = NioUtils.unsafeArrayOffset(b) + b.position();
    }
    byteCounts[i] = remaining;
    totalRemaining += remaining;
  }
  return totalRemaining;
}

相关文章