net.i2p.data.Hash.writeBytes()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(182)

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

Hash.writeBytes介绍

暂无

代码示例

代码示例来源:origin: i2p/i2p.i2p

protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_hash == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(Hash.HASH_LENGTH);
  try {
    _hash.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the hash", dfe);
  }
  return os.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p

@Override
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
  if (_gateway == null)
    throw new DataFormatException("Not enough data to write out a Lease");
  _gateway.writeBytes(out);
  // flags
  DataHelper.writeLong(out, 2, 0);
  out.write(_type);
  out.write(_cost);
  DataHelper.writeLong(out, 4, _end.getTime() / 1000);
}

代码示例来源:origin: i2p/i2p.i2p

@Override
public void writeBytes(OutputStream out) throws DataFormatException, IOException {
  if ((_gateway == null) || (_tunnelId == null))
    throw new DataFormatException("Not enough data to write out a Lease");
  _gateway.writeBytes(out);
  _tunnelId.writeBytes(out);
  DataHelper.writeLong(out, 4, _end.getTime() / 1000);
}

代码示例来源:origin: i2p/i2p.i2p

public void writeBytes(OutputStream out) throws DataFormatException, IOException {
  if ((_gateway == null) || (_tunnelId == null))
    throw new DataFormatException("Not enough data to write out a Lease");
  _gateway.writeBytes(out);
  _tunnelId.writeBytes(out);
  DataHelper.writeDate(out, _end);
}

代码示例来源:origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(256);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 1, _endpoints.size());
    for (int i = 0; i < _endpoints.size(); i++) {
      Hash router = getRouter(i);
      router.writeBytes(os);
      TunnelId tunnel = getTunnelId(i);
      tunnel.writeBytes(os);
    }
    DataHelper.writeDate(os, _end);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p

peerHash.writeBytes(out);

代码示例来源:origin: i2p/i2p.i2p

protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  int len;
  if (_lookupType == LOOKUP_HASH) {
    if (_hash == null)
      throw new I2CPMessageException("Unable to write out the message as there is not enough data");
    len = 11 + Hash.HASH_LENGTH;
  } else if (_lookupType == LOOKUP_HOST) {
    if (_host == null)
      throw new I2CPMessageException("Unable to write out the message as there is not enough data");
    len = 12 + _host.length();
  } else {
    throw new I2CPMessageException("bad type");
  }
  ByteArrayOutputStream os = new ByteArrayOutputStream(len);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 4, _reqID);
    DataHelper.writeLong(os, 4, _timeout);
    DataHelper.writeLong(os, 1, _lookupType);
    if (_lookupType == LOOKUP_HASH) {
      _hash.writeBytes(os);
    } else {
      DataHelper.writeString(os, _host);
    }
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("bad data", dfe);
  }
  return os.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p

ByteArrayOutputStream baos = new ByteArrayOutputStream(datalen);
for (int i = 0; i < size; i++) {
  _leases.get(i).getGateway().writeBytes(baos);
  _leases.get(i).getTunnelId().writeBytes(baos);

代码示例来源:origin: i2p/i2p.i2p

ByteArrayOutputStream baos = new ByteArrayOutputStream(datalen);
for (int i = 0; i < size; i++) {
  _leases.get(i).getGateway().writeBytes(baos);
  _leases.get(i).getTunnelId().writeBytes(baos);

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(byteStream);
  
  try {
    writeHeader(dataStream);
    emailDestHash.writeBytes(dataStream);
    dataStream.writeShort(entries.size());
    for (Entry<Hash, UniqueId> entry: entries.entrySet()) {
      dataStream.write(entry.getKey().toByteArray());
      dataStream.write(entry.getValue().toByteArray());
    }
  } catch (DataFormatException e) {
    log.error("Invalid format for email destination.", e);
  } catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream.", e);
  }
  
  return byteStream.toByteArray();
}

代码示例来源:origin: i2p/i2p.i2p-bote

@Override
public byte[] toByteArray() {
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
  DataOutputStream dataStream = new DataOutputStream(byteStream);
  try {
    writeHeader(dataStream);
    
    destinationHash.writeBytes(dataStream);
    dataStream.writeInt(entries.size());
    for (IndexPacketEntry entry: entries) {
      dataStream.write(entry.emailPacketKey.toByteArray());
      dataStream.write(entry.delVerificationHash.toByteArray());
      dataStream.writeInt((int)(entry.storeTime/1000L));   // store as seconds
    }
  }
  catch (IOException e) {
    log.error("Can't write to ByteArrayOutputStream/DataOutputStream.", e);
  } catch (DataFormatException e) {
    log.error("Can't write destination hash to output stream: " + destinationHash, e);
  }
  return byteStream.toByteArray();
}

相关文章