org.apache.activemq.util.ByteArrayOutputStream.toByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(150)

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

ByteArrayOutputStream.toByteArray介绍

暂无

代码示例

代码示例来源:origin: apache/activemq

protected void sendWriteBuffer(SocketAddress address, ByteArrayOutputStream writeBuffer, int commandId) throws IOException {
  byte[] data = writeBuffer.toByteArray();
  sendWriteBuffer(commandId, address, data, false);
}

代码示例来源:origin: apache/activemq

protected byte[] decompress(ByteSequence dataSequence) throws IOException {
  Inflater inflater = new Inflater();
  ByteArrayOutputStream decompressed = new ByteArrayOutputStream();
  try {
    length = ByteSequenceData.readIntBig(dataSequence);
    dataSequence.offset = 0;
    byte[] data = Arrays.copyOfRange(dataSequence.getData(), 4, dataSequence.getLength());
    inflater.setInput(data);
    byte[] buffer = new byte[length];
    int count = inflater.inflate(buffer);
    decompressed.write(buffer, 0, count);
    return decompressed.toByteArray();
  } catch (Exception e) {
    throw new IOException(e);
  } finally {
    inflater.end();
    decompressed.close();
  }
}

代码示例来源:origin: apache/activemq

@Override
public byte[] doGetMessage(TransactionContext c, MessageId id) throws SQLException, IOException {
  PreparedStatement s = null;
  ResultSet rs = null;
  try {
    s = c.getConnection().prepareStatement(statements.getFindMessageStatement());
    s.setString(1, id.getProducerId().toString());
    s.setLong(2, id.getProducerSequenceId());
    rs = s.executeQuery();
    if (!rs.next()) {
      return null;
    }
    Blob blob = rs.getBlob(1);
    try(InputStream is = blob.getBinaryStream();
      ByteArrayOutputStream os = new ByteArrayOutputStream((int)blob.length())) {
      int ch;
      while ((ch = is.read()) >= 0) {
        os.write(ch);
      }
      return os.toByteArray();
    }
  } finally {
    close(rs);
    close(s);
  }
}

代码示例来源:origin: apache/activemq

byte[] data = largeBuffer.toByteArray();
int size = data.length;

代码示例来源:origin: apache/activemq

} else {
  byte[] data = writeBuffer.toByteArray();
  boolean lastFragment = false;
  int length = data.length;

代码示例来源:origin: apache/nifi

cacheEntries.put(signalId, new AtomicCacheEntry<>(signalId, new String(bos.toByteArray(), StandardCharsets.UTF_8), 0L));

代码示例来源:origin: org.apache.activemq/activemq-all

protected void sendWriteBuffer(SocketAddress address, ByteArrayOutputStream writeBuffer, int commandId) throws IOException {
  byte[] data = writeBuffer.toByteArray();
  sendWriteBuffer(commandId, address, data, false);
}

代码示例来源:origin: org.apache.activemq/activemq-all

private static byte[] getSerializedBytes(Serializable value) throws IOException {
  try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
     ObjectOutputStream oos = new ObjectOutputStream(baos)) {
    oos.writeObject(value);
    oos.flush();
    oos.close();
    return baos.toByteArray();
  }
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

private static byte[] getSerializedBytes(Serializable value) throws IOException {
  try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
     ObjectOutputStream oos = new ObjectOutputStream(baos)) {
    oos.writeObject(value);
    oos.flush();
    oos.close();
    return baos.toByteArray();
  }
}

代码示例来源:origin: pierre/meteo

protected void sendWriteBuffer(SocketAddress address, ByteArrayOutputStream writeBuffer, int commandId) throws IOException {
  byte[] data = writeBuffer.toByteArray();
  sendWriteBuffer(commandId, address, data, false);
}

代码示例来源:origin: org.apache.activemq/activemq-client

protected void sendWriteBuffer(SocketAddress address, ByteArrayOutputStream writeBuffer, int commandId) throws IOException {
  byte[] data = writeBuffer.toByteArray();
  sendWriteBuffer(commandId, address, data, false);
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

protected void sendWriteBuffer(SocketAddress address, ByteArrayOutputStream writeBuffer, int commandId) throws IOException {
  byte[] data = writeBuffer.toByteArray();
  sendWriteBuffer(commandId, address, data, false);
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

protected void processCommand() throws Exception {
  StompFrame frame = new StompFrame(action, headers, currentCommand.toByteArray());
  transport.doConsume(frame);
  processedHeaders = false;
  awaitingCommandStart = true;
  currentCommand.reset();
  contentLength = -1;
  frameSize.set(0);
}

代码示例来源:origin: org.apache.activemq/activemq-all

protected void processCommand() throws Exception {
  StompFrame frame = new StompFrame(action, headers, currentCommand.toByteArray());
  transport.doConsume(frame);
  processedHeaders = false;
  awaitingCommandStart = true;
  currentCommand.reset();
  contentLength = -1;
  frameSize.set(0);
}

代码示例来源:origin: org.apache.activemq/activemq-stomp

protected void processCommand() throws Exception {
  StompFrame frame = new StompFrame(action, headers, currentCommand.toByteArray());
  transport.doConsume(frame);
  processedHeaders = false;
  awaitingCommandStart = true;
  currentCommand.reset();
  contentLength = -1;
  frameSize.set(0);
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

protected byte[] decompress(ByteSequence dataSequence) throws IOException {
  Inflater inflater = new Inflater();
  ByteArrayOutputStream decompressed = new ByteArrayOutputStream();
  try {
    length = ByteSequenceData.readIntBig(dataSequence);
    dataSequence.offset = 0;
    byte[] data = Arrays.copyOfRange(dataSequence.getData(), 4, dataSequence.getLength());
    inflater.setInput(data);
    byte[] buffer = new byte[length];
    int count = inflater.inflate(buffer);
    decompressed.write(buffer, 0, count);
    return decompressed.toByteArray();
  } catch (Exception e) {
    throw new IOException(e);
  } finally {
    inflater.end();
    decompressed.close();
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

protected byte[] decompress(ByteSequence dataSequence) throws IOException {
  Inflater inflater = new Inflater();
  ByteArrayOutputStream decompressed = new ByteArrayOutputStream();
  try {
    length = ByteSequenceData.readIntBig(dataSequence);
    dataSequence.offset = 0;
    byte[] data = Arrays.copyOfRange(dataSequence.getData(), 4, dataSequence.getLength());
    inflater.setInput(data);
    byte[] buffer = new byte[length];
    int count = inflater.inflate(buffer);
    decompressed.write(buffer, 0, count);
    return decompressed.toByteArray();
  } catch (Exception e) {
    throw new IOException(e);
  } finally {
    inflater.end();
    decompressed.close();
  }
}

代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq

protected void processCommand() throws Exception {
    StompFrame frame = new StompFrame(action, headers, currentCommand.toByteArray());
    writeStream.consume(frame);
    processedHeaders = false;
    awaitingCommandStart = true;
    currentCommand.reset();
    contentLength = -1;
  }
}

代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq

protected void processCommand() throws Exception {
    StompFrame frame = new StompFrame(action, headers, currentCommand.toByteArray());
    writeStream.consume(frame);
    processedHeaders = false;
    awaitingCommandStart = true;
    currentCommand.reset();
    contentLength = -1;
  }
}

代码示例来源:origin: pierre/meteo

private void processCommand() throws Exception {
  StompFrame frame = new StompFrame(action, headers, currentCommand.toByteArray());
  doConsume(frame);
  processedHeaders = false;
  currentCommand.reset();
  contentLength = -1;
}

相关文章