org.bitcoinj.core.Utils.copyOf()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(115)

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

Utils.copyOf介绍

暂无

代码示例

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Creates a newly allocated byte array. Its size is the current
 * size of this output stream and the valid contents of the buffer
 * have been copied into it.
 *
 * @return the current contents of this output stream, as a byte array.
 * @see java.io.ByteArrayOutputStream#size()
 */
@Override
public byte toByteArray()[] {
  return count == buf.length ? buf : Utils.copyOf(buf, count);
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Creates a newly allocated byte array. Its size is the current
 * size of this output stream and the valid contents of the buffer
 * have been copied into it.
 *
 * @return the current contents of this output stream, as a byte array.
 * @see java.io.ByteArrayOutputStream#size()
 */
@Override
public byte toByteArray()[] {
  return count == buf.length ? buf : Utils.copyOf(buf, count);
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Creates a newly allocated byte array. Its size is the current
 * size of this output stream and the valid contents of the buffer
 * have been copied into it.
 *
 * @return the current contents of this output stream, as a byte array.
 * @see java.io.ByteArrayOutputStream#size()
 */
@Override
public byte toByteArray()[] {
  return count == buf.length ? buf : Utils.copyOf(buf, count);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Creates a newly allocated byte array. Its size is the current
 * size of this output stream and the valid contents of the buffer
 * have been copied into it.
 *
 * @return the current contents of this output stream, as a byte array.
 * @see java.io.ByteArrayOutputStream#size()
 */
@Override
public byte toByteArray()[] {
  return count == buf.length ? buf : Utils.copyOf(buf, count);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Writes the specified byte to this byte array output stream.
 *
 * @param b the byte to be written.
 */
@Override
public void write(int b) {
  int newcount = count + 1;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  buf[count] = (byte) b;
  count = newcount;
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Writes the specified byte to this byte array output stream.
 *
 * @param b the byte to be written.
 */
@Override
public void write(int b) {
  int newcount = count + 1;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  buf[count] = (byte) b;
  count = newcount;
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Writes the specified byte to this byte array output stream.
 *
 * @param b the byte to be written.
 */
@Override
public void write(int b) {
  int newcount = count + 1;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  buf[count] = (byte) b;
  count = newcount;
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Writes the specified byte to this byte array output stream.
 *
 * @param b the byte to be written.
 */
@Override
public void write(int b) {
  int newcount = count + 1;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  buf[count] = (byte) b;
  count = newcount;
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Writes <code>len</code> bytes from the specified byte array
 * starting at offset <code>off</code> to this byte array output stream.
 *
 * @param b   the data.
 * @param off the start offset in the data.
 * @param len the number of bytes to write.
 */
@Override
public void write(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
      ((off + len) > b.length) || ((off + len) < 0)) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return;
  }
  int newcount = count + len;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  System.arraycopy(b, off, buf, count, len);
  count = newcount;
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Writes <code>len</code> bytes from the specified byte array
 * starting at offset <code>off</code> to this byte array output stream.
 *
 * @param b   the data.
 * @param off the start offset in the data.
 * @param len the number of bytes to write.
 */
@Override
public void write(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
      ((off + len) > b.length) || ((off + len) < 0)) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return;
  }
  int newcount = count + len;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  System.arraycopy(b, off, buf, count, len);
  count = newcount;
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Writes <code>len</code> bytes from the specified byte array
 * starting at offset <code>off</code> to this byte array output stream.
 *
 * @param b   the data.
 * @param off the start offset in the data.
 * @param len the number of bytes to write.
 */
@Override
public void write(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
      ((off + len) > b.length) || ((off + len) < 0)) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return;
  }
  int newcount = count + len;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  System.arraycopy(b, off, buf, count, len);
  count = newcount;
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Writes {@code len} bytes from the specified byte array
 * starting at offset {@code off} to this byte array output stream.
 *
 * @param b   the data.
 * @param off the start offset in the data.
 * @param len the number of bytes to write.
 */
@Override
public void write(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
      ((off + len) > b.length) || ((off + len) < 0)) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return;
  }
  int newcount = count + len;
  if (newcount > buf.length) {
    buf = Utils.copyOf(buf, Math.max(buf.length << 1, newcount));
  }
  System.arraycopy(b, off, buf, count, len);
  count = newcount;
}

相关文章