org.apache.commons.io.output.ByteArrayOutputStream.getBuffer()方法的使用及代码示例

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

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

ByteArrayOutputStream.getBuffer介绍

[英]Return the appropriate byte[] buffer specified by index.
[中]返回索引指定的相应byte[]缓冲区。

代码示例

代码示例来源:origin: org.apache.commons/commons-io

/**
 * @see java.io.ByteArrayOutputStream#reset()
 */
public synchronized void reset() {
  count = 0;
  filledBufferSum = 0;
  currentBufferIndex = 0;
  currentBuffer = getBuffer(currentBufferIndex);
}

代码示例来源:origin: org.apache.commons/commons-io

/**
 * Writes the entire contents of this byte stream to the
 * specified output stream.
 *
 * @param out  the output stream to write to
 * @throws IOException if an I/O error occurs, such as if the stream is closed
 * @see java.io.ByteArrayOutputStream#writeTo(OutputStream)
 */
public synchronized void writeTo(OutputStream out) throws IOException {
  int remaining = count;
  for (int i = 0; i < buffers.size(); i++) {
    byte[] buf = getBuffer(i);
    int c = Math.min(buf.length, remaining);
    out.write(buf, 0, c);
    remaining -= c;
    if (remaining == 0) {
      break;
    }
  }
}

代码示例来源:origin: org.apache.commons/commons-io

currentBuffer = getBuffer(currentBufferIndex);
} else {

代码示例来源:origin: org.apache.commons/commons-io

/**
 * Gets the curent contents of this byte stream as a byte array.
 * The result is independent of this stream.
 *
 * @return the current contents of this output stream, as a byte array
 * @see java.io.ByteArrayOutputStream#toByteArray()
 */
public synchronized byte[] toByteArray() {
  int remaining = count;
  if (remaining == 0) {
    return EMPTY_BYTE_ARRAY; 
  }
  byte newbuf[] = new byte[remaining];
  int pos = 0;
  for (int i = 0; i < buffers.size(); i++) {
    byte[] buf = getBuffer(i);
    int c = Math.min(buf.length, remaining);
    System.arraycopy(buf, 0, newbuf, pos, c);
    pos += c;
    remaining -= c;
    if (remaining == 0) {
      break;
    }
  }
  return newbuf;
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io

/**
 * @see java.io.ByteArrayOutputStream#reset()
 */
public synchronized void reset() {
  count = 0;
  filledBufferSum = 0;
  currentBufferIndex = 0;
  currentBuffer = getBuffer(currentBufferIndex);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io

/**
 * @see java.io.ByteArrayOutputStream#reset()
 */
public synchronized void reset() {
  count = 0;
  filledBufferSum = 0;
  currentBufferIndex = 0;
  currentBuffer = getBuffer(currentBufferIndex);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io

/**
 * Writes the entire contents of this byte stream to the
 * specified output stream.
 *
 * @param out  the output stream to write to
 * @throws IOException if an I/O error occurs, such as if the stream is closed
 * @see java.io.ByteArrayOutputStream#writeTo(OutputStream)
 */
public synchronized void writeTo(OutputStream out) throws IOException {
  int remaining = count;
  for (int i = 0; i < buffers.size(); i++) {
    byte[] buf = getBuffer(i);
    int c = Math.min(buf.length, remaining);
    out.write(buf, 0, c);
    remaining -= c;
    if (remaining == 0) {
      break;
    }
  }
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io

/**
 * Writes the entire contents of this byte stream to the
 * specified output stream.
 *
 * @param out  the output stream to write to
 * @throws IOException if an I/O error occurs, such as if the stream is closed
 * @see java.io.ByteArrayOutputStream#writeTo(OutputStream)
 */
public synchronized void writeTo(OutputStream out) throws IOException {
  int remaining = count;
  for (int i = 0; i < buffers.size(); i++) {
    byte[] buf = getBuffer(i);
    int c = Math.min(buf.length, remaining);
    out.write(buf, 0, c);
    remaining -= c;
    if (remaining == 0) {
      break;
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io

/**
 * Gets the curent contents of this byte stream as a byte array.
 * The result is independent of this stream.
 *
 * @return the current contents of this output stream, as a byte array
 * @see java.io.ByteArrayOutputStream#toByteArray()
 */
public synchronized byte[] toByteArray() {
  int remaining = count;
  if (remaining == 0) {
    return EMPTY_BYTE_ARRAY; 
  }
  byte newbuf[] = new byte[remaining];
  int pos = 0;
  for (int i = 0; i < buffers.size(); i++) {
    byte[] buf = getBuffer(i);
    int c = Math.min(buf.length, remaining);
    System.arraycopy(buf, 0, newbuf, pos, c);
    pos += c;
    remaining -= c;
    if (remaining == 0) {
      break;
    }
  }
  return newbuf;
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io

/**
 * Gets the curent contents of this byte stream as a byte array.
 * The result is independent of this stream.
 *
 * @return the current contents of this output stream, as a byte array
 * @see java.io.ByteArrayOutputStream#toByteArray()
 */
public synchronized byte[] toByteArray() {
  int remaining = count;
  if (remaining == 0) {
    return EMPTY_BYTE_ARRAY; 
  }
  byte newbuf[] = new byte[remaining];
  int pos = 0;
  for (int i = 0; i < buffers.size(); i++) {
    byte[] buf = getBuffer(i);
    int c = Math.min(buf.length, remaining);
    System.arraycopy(buf, 0, newbuf, pos, c);
    pos += c;
    remaining -= c;
    if (remaining == 0) {
      break;
    }
  }
  return newbuf;
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io

currentBuffer = getBuffer(currentBufferIndex);
} else {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io

currentBuffer = getBuffer(currentBufferIndex);
} else {

相关文章