List of usage examples for com.google.common.io ByteArrayDataOutput write
@Override void write(byte b[]);
From source file:org.elasticsoftware.elasticactors.cassandra.serialization.CompressingSerializer.java
@Override public byte[] serialize(I object) throws IOException { byte[] serializedObject = delegate.serialize(object); if (serializedObject.length > compressionThreshold) { byte[] compressedBytes = lz4Compressor.compress(serializedObject); ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(compressedBytes.length + 8); dataOutput.write(MAGIC_HEADER); dataOutput.writeInt(serializedObject.length); dataOutput.write(compressedBytes); return dataOutput.toByteArray(); } else {// w ww. j a v a 2s . co m return serializedObject; } }
From source file:org.elasticsoftware.elasticactors.cassandra2.serialization.CompressingSerializer.java
@Override public ByteBuffer serialize(I object) throws IOException { byte[] serializedObject = delegate.serialize(object); if (serializedObject.length > compressionThreshold) { byte[] compressedBytes = lz4Compressor.compress(serializedObject); ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(compressedBytes.length + 8); dataOutput.write(MAGIC_HEADER); dataOutput.writeInt(serializedObject.length); dataOutput.write(compressedBytes); return ByteBuffer.wrap(dataOutput.toByteArray()); } else {/* w w w . j a va2 s .com*/ return ByteBuffer.wrap(serializedObject); } }
From source file:garmintools.adapters.garmin.MetadataGarminAdapter.java
private void writePreamble(ByteArrayDataOutput output) { output.write(DEFAULT_PREAMBLE_LENGTH); for (int i = 0; i < DEFAULT_PREAMBLE_LENGTH; ++i) { output.write(i);//from w w w. ja v a 2s . c o m } }
From source file:org.xdi.oxauth.service.fido.u2f.RawRegistrationService.java
private byte[] packBytesToSign(byte[] appIdHash, byte[] clientDataHash, byte[] keyHandle, byte[] userPublicKey) { ByteArrayDataOutput encoded = ByteStreams.newDataOutput(); encoded.write(REGISTRATION_SIGNED_RESERVED_BYTE_VALUE); encoded.write(appIdHash);// w w w . j a v a 2 s .c o m encoded.write(clientDataHash); encoded.write(keyHandle); encoded.write(userPublicKey); return encoded.toByteArray(); }
From source file:com.google.devrel.gmscore.tools.apk.arsc.ResourceFile.java
@Override public byte[] toByteArray(boolean shrink) throws IOException { ByteArrayDataOutput output = ByteStreams.newDataOutput(); for (Chunk chunk : chunks) { output.write(chunk.toByteArray(shrink)); }/*from w ww .j a va 2 s .c om*/ return output.toByteArray(); }
From source file:garmintools.adapters.garmin.MetadataGarminAdapter.java
private void writeDate(ByteArrayDataOutput output, Proto.Date date) { output.write(date.getMonth()); output.write(date.getDay());//from www. j a v a2 s .c om output.writeShort(date.getYear()); }
From source file:de.paleocrafter.pmfw.network.packet.TileDataPacket.java
@Override public void write(ByteArrayDataOutput out) { out.writeInt(x);//w w w . j a va2 s .c om out.writeInt(y); out.writeInt(z); out.writeInt(data.length); out.write(data); }
From source file:garmintools.adapters.garmin.MetadataGarminAdapter.java
private void writeStringAndPadWithSpace(ByteArrayDataOutput output, String string, int paddedLength) { byte b[] = string.getBytes(Charsets.US_ASCII); output.write(b); output.write(0);// w w w . j a v a2 s . co m Preconditions.checkArgument(b.length + 1 <= paddedLength); for (int i = b.length + 1; i < paddedLength; ++i) { output.write(32); } }
From source file:com.galois.qrstream.qrpipe.DecodedMessage.java
/** * Returns the whole transmitted message whenever it is available, otherwise * it returns an empty message to indicate only partial message received. *//*from www .ja va 2 s . co m*/ public byte[] getEntireMessage() { if (receivedData.isEmpty() || (decodeState.getState() != State.Final)) { return new byte[0]; } // Assemble message in order, we assume key are sorted ByteArrayDataOutput bstream = ByteStreams.newDataOutput(); for (Entry<Integer, PartialMessage> entry : receivedData.entrySet()) { bstream.write(entry.getValue().getPayload()); } return bstream.toByteArray(); }
From source file:com.netease.flume.taildirSource.TailFile.java
private String readLine() throws IOException { ByteArrayDataOutput out = ByteStreams.newDataOutput(300); int i = 0;/*from www . j av a2 s . c om*/ int c; while ((c = raf.read()) != -1) { i++; out.write((byte) c); if (c == LINE_SEP.charAt(0)) { break; } } if (i == 0) { return null; } return new String(out.toByteArray(), Charsets.UTF_8); }