本文整理了Java中org.apache.activemq.util.ByteArrayInputStream
类的一些代码示例,展示了ByteArrayInputStream
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteArrayInputStream
类的具体详情如下:
包路径:org.apache.activemq.util.ByteArrayInputStream
类名称:ByteArrayInputStream
[英]Very similar to the java.io.ByteArrayInputStream but this version is not thread safe.
[中]与java非常相似。木卫一。ByteArrayInputStream,但此版本不是线程安全的。
代码示例来源:origin: apache/activemq
private String decodeContent(ByteSequence bodyAsBytes) throws JMSException {
String text = null;
if (bodyAsBytes != null) {
InputStream is = null;
try {
is = new ByteArrayInputStream(bodyAsBytes);
if (isCompressed()) {
is = new InflaterInputStream(is);
}
DataInputStream dataIn = new DataInputStream(is);
text = MarshallingSupport.readUTF8(dataIn);
dataIn.close();
} catch (IOException ioe) {
throw JMSExceptionSupport.create(ioe);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
}
return text;
}
代码示例来源:origin: apache/activemq
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
代码示例来源:origin: apache/activemq
public Object unmarshal(ByteSequence packet) throws IOException {
return unmarshal(new DataInputStream(new ByteArrayInputStream(packet)));
}
代码示例来源:origin: apache/activemq-artemis
private static void writeStreamType(final ByteSequence contents,
final boolean messageCompressed,
final ActiveMQBuffer body) throws IOException {
InputStream sis = new ByteArrayInputStream(contents);
if (messageCompressed) {
sis = new InflaterInputStream(sis);
DataInputStream sdis = new DataInputStream(sis);
int stype = sdis.read();
while (stype != -1) {
switch (stype) {
case MarshallingSupport.BOOLEAN_TYPE:
body.writeByte(DataConstants.BOOLEAN);
body.writeBoolean(sdis.readBoolean());
break;
case MarshallingSupport.BYTE_TYPE:
case MarshallingSupport.BIG_STRING_TYPE:
body.writeByte(DataConstants.STRING);
String sbigString = MarshallingSupport.readUTF8(sdis);
body.writeNullableString(sbigString);
break;
代码示例来源:origin: apache/activemq
private Map<String, Object> unmarsallProperties(ByteSequence marshalledProperties) throws IOException {
return MarshallingSupport.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)), MAX_PROPERTY_SIZE);
}
代码示例来源:origin: org.apache.activemq/activemq-all
try (ByteArrayInputStream is = new ByteArrayInputStream(contents);
InflaterInputStream iis = new InflaterInputStream(is);
DataInputStream dis = new DataInputStream(iis);) {
int size = dis.readInt();
byte[] uncompressed = new byte[size];
dis.readFully(uncompressed);
result = new Binary(contents.getData(), contents.getOffset() + 4, contents.getLength() - 4);
代码示例来源:origin: pierre/meteo
private void initializeReading() throws JMSException {
checkWriteOnlyBody();
if (dataIn == null) {
ByteSequence data = getContent();
if (data == null) {
data = new ByteSequence(new byte[] {}, 0, 0);
}
InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) {
// keep track of the real length of the content if
// we are compressed.
try {
DataInputStream dis = new DataInputStream(is);
length = dis.readInt();
dis.close();
} catch (IOException e) {
throw JMSExceptionSupport.create(e);
}
is = new InflaterInputStream(is);
} else {
length = data.getLength();
}
dataIn = new DataInputStream(is);
}
}
代码示例来源:origin: apache/activemq
private void initializeReading() throws MessageNotReadableException {
checkWriteOnlyBody();
if (this.dataIn == null) {
ByteSequence data = getContent();
if (data == null) {
data = new ByteSequence(new byte[] {}, 0, 0);
}
InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) {
is = new InflaterInputStream(is);
is = new BufferedInputStream(is);
}
this.dataIn = new DataInputStream(is);
}
}
代码示例来源:origin: apache/activemq
private void initializeReading() throws JMSException {
checkWriteOnlyBody();
if (dataIn == null) {
try {
ByteSequence data = getContent();
if (data == null) {
data = new ByteSequence(new byte[] {}, 0, 0);
}
InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) {
if (data.length != 0) {
is = new ByteArrayInputStream(decompress(data));
}
} else {
length = data.getLength();
}
dataIn = new DataInputStream(is);
} catch (IOException ioe) {
throw JMSExceptionSupport.create(ioe);
}
}
}
代码示例来源:origin: apache/activemq
try {
if (compressed) {
ByteArrayInputStream input = new ByteArrayInputStream(this.content.getData(), this.content.getOffset(), this.content.getLength());
InflaterInputStream inflater = new InflaterInputStream(input);
try {
byte[] buffer = new byte[8*1024];
int read = 0;
while ((read = inflater.read(buffer)) != -1) {
this.dataOut.write(buffer, 0, read);
inflater.close();
代码示例来源:origin: apache/activemq-artemis
private static ByteSequence writeCompressedObjectType(final ByteSequence contents) throws IOException {
try (InputStream ois = new InflaterInputStream(new ByteArrayInputStream(contents));
org.apache.activemq.util.ByteArrayOutputStream decompressed = new org.apache.activemq.util.ByteArrayOutputStream()) {
byte[] buf = new byte[1024];
int n = ois.read(buf);
while (n != -1) {
decompressed.write(buf, 0, n);
n = ois.read();
}
//read done
return decompressed.toByteSequence();
}
}
代码示例来源:origin: org.apache.activemq/activemq-all
ByteArrayInputStream headerLine = new ByteArrayInputStream(line);
ByteArrayOutputStream stream = new ByteArrayOutputStream(line.length);
while ((result = headerLine.read()) != -1) {
if (result != ':') {
stream.write(result);
String name = new String(nameSeq.getData(), nameSeq.getOffset(), nameSeq.getLength(), "UTF-8");
String value = decodeHeader(headerLine);
if (stompVersion.equals(Stomp.V1_0)) {
代码示例来源:origin: apache/activemq
/**
* @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#setBinaryData(java.sql.PreparedStatement,
* int, byte[])
*/
@Override
protected void setBinaryData(PreparedStatement s, int index, byte[] data) throws SQLException {
s.setBinaryStream(index, new ByteArrayInputStream(data), data.length);
}
代码示例来源:origin: apache/activemq
public Command read() throws IOException {
Command answer = null;
Endpoint from = null;
synchronized (readLock) {
while (true) {
DatagramPacket datagram = createDatagramPacket();
channel.receive(datagram);
// TODO could use a DataInput implementation that talks direct
// to the byte[] to avoid object allocation
receiveCounter++;
DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(datagram.getData(), 0, datagram.getLength()));
from = headerMarshaller.createEndpoint(datagram, dataIn);
answer = (Command)wireFormat.unmarshal(dataIn);
break;
}
}
if (answer != null) {
answer.setFrom(from);
if (LOG.isDebugEnabled()) {
LOG.debug("Channel: " + name + " about to process: " + answer);
}
}
return answer;
}
代码示例来源:origin: apache/activemq
private Map<String, Object> unmarsallProperties(ByteSequence marshalledProperties) throws IOException {
return MarshallingSupport.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)));
}
代码示例来源:origin: org.apache.activemq/activemq-osgi
try (ByteArrayInputStream is = new ByteArrayInputStream(contents);
InflaterInputStream iis = new InflaterInputStream(is);
DataInputStream dis = new DataInputStream(iis);) {
int size = dis.readInt();
byte[] uncompressed = new byte[size];
dis.readFully(uncompressed);
result = new Binary(contents.getData(), contents.getOffset() + 4, contents.getLength() - 4);
代码示例来源:origin: org.apache.activemq/activemq-all
private void initializeReading() throws MessageNotReadableException {
checkWriteOnlyBody();
if (this.dataIn == null) {
ByteSequence data = getContent();
if (data == null) {
data = new ByteSequence(new byte[] {}, 0, 0);
}
InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) {
is = new InflaterInputStream(is);
is = new BufferedInputStream(is);
}
this.dataIn = new DataInputStream(is);
}
}
代码示例来源:origin: org.apache.activemq/activemq-client
private void initializeReading() throws JMSException {
checkWriteOnlyBody();
if (dataIn == null) {
try {
ByteSequence data = getContent();
if (data == null) {
data = new ByteSequence(new byte[] {}, 0, 0);
}
InputStream is = new ByteArrayInputStream(data);
if (isCompressed()) {
if (data.length != 0) {
is = new ByteArrayInputStream(decompress(data));
}
} else {
length = data.getLength();
}
dataIn = new DataInputStream(is);
} catch (IOException ioe) {
throw JMSExceptionSupport.create(ioe);
}
}
}
代码示例来源:origin: org.apache.activemq/activemq-all
try {
if (compressed) {
ByteArrayInputStream input = new ByteArrayInputStream(this.content.getData(), this.content.getOffset(), this.content.getLength());
InflaterInputStream inflater = new InflaterInputStream(input);
try {
byte[] buffer = new byte[8*1024];
int read = 0;
while ((read = inflater.read(buffer)) != -1) {
this.dataOut.write(buffer, 0, read);
inflater.close();
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
ByteArrayInputStream headerLine = new ByteArrayInputStream(line);
ByteArrayOutputStream stream = new ByteArrayOutputStream(line.length);
while ((result = headerLine.read()) != -1) {
if (result != ':') {
stream.write(result);
String name = new String(nameSeq.getData(), nameSeq.getOffset(), nameSeq.getLength(), "UTF-8");
String value = decodeHeader(headerLine);
if (stompVersion.equals(Stomp.V1_0)) {
内容来源于网络,如有侵权,请联系作者删除!