Java 8 DataInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DataInputStream class.

This code example shows how to use the following methods:read, readBoolean, readShort
        this.marshallerFactory = marshallerFactory;
    } 
 
    @Override 
    public void processMessage(final ChannelAssociation channelAssociation, final InputStream inputStream) throws IOException {
        final DataInputStream input = new DataInputStream(inputStream);
        // read the invocation id 
        final short invocationId = input.readShort();
        // read the transaction id length 
        final int transactionIDBytesLength = PackedInteger.readPackedInteger(input);
        // read the transaction id bytes 
        final byte[] transactionIDBytes = new byte[transactionIDBytesLength];
        input.read(transactionIDBytes);
        final TransactionID transactionID = TransactionID.createTransactionID(transactionIDBytes);
        // if it's a commit request, the read the additional "bit" which indicates whether it's a one-phase 
        // commit request 
        boolean onePhaseCommit = false;
        if (this.txRequestType == TransactionRequestType.COMMIT) {
            onePhaseCommit = input.readBoolean();
        } 

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readByte, readInt, readLong
        bb.putInt(255);
        bb.put((byte) -3);
        bb.putLong(42L);
        bb.clear();
 
        DataInputStream in = new DataInputStream(ByteBufferUtil.inputStream(bb));
        assert in.readInt() == 255;
        assert in.readByte() == (byte)-3;
        assert in.readLong() == 42L;
    } 
 
    @Test 
    public void testIntBytesConversions() 
    { 
        // positive, negative, 1 and 2 byte cases, including a few edges that would foul things up unless you're careful 
        // about masking away sign extension. 
        int[] ints = new int[]
        { 
            -20, -127, -128, 0, 1, 127, 128, 65534, 65535, -65534, -65535 
        }; 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readInt, readShort, readUTF
        this.marshallerFactory = marshallerFactory;
    } 
 
    @Override 
    public void processMessage(ChannelAssociation channelAssociation, InputStream inputStream) throws IOException {
        final DataInputStream input = new DataInputStream(inputStream);
        // read the invocation id 
        final short invocationId = input.readShort();
        final String txParentNodeName = input.readUTF();
        final int recoveryFlags = input.readInt();
        executorService.submit(new TxRecoveryTask(channelAssociation, invocationId, txParentNodeName, recoveryFlags));
    } 
 
    private final class TxRecoveryTask implements Runnable {
 
        private final String txParentNodeName;
        private final short invocationId;
        private final ChannelAssociation channelAssociation;
        private final int recoveryFlags;
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readBoolean, readInt
		plugMatrix.writeData(data);
	} 
 
	@Override 
	public void readData(DataInputStream data) throws IOException {
		hasGate = data.readBoolean();
		gateIconIndex = data.readInt();
		pipeConnectionMatrix.readData(data);
		textureMatrix.readData(data);
		wireMatrix.readData(data);
		facadeMatrix.readData(data);
		plugMatrix.readData(data);
	} 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    tbw.setValue(12345);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutput dout = new DataOutputStream(baos);
    tbw.write(dout);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    DataInput din = new DataInputStream(bais);
    TypedBytesWritable readTbw = new TypedBytesWritable();
    readTbw.readFields(din);
    assertEquals(tbw, readTbw);
  } 
 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readInt
		data.writeInt(entityId);
	} 
 
	@Override 
	public void readData(DataInputStream data) throws IOException {
		super.readData(data);
		entityId = data.readInt();
	} 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close
      DataInputStream in = null;
      try { 
        FileSystem fs = dirName.getFileSystem(conf);
        in = fs.open(new Path(dirName, BLOOM_FILE_NAME));
        bloomFilter = new DynamicBloomFilter();
        bloomFilter.readFields(in);
        in.close();
        in = null;
      } catch (IOException ioe) {
        LOG.warn("Can't open BloomFilter: " + ioe + " - fallback to MapFile.");
        bloomFilter = null;
      } finally { 
        IOUtils.closeStream(in);
      } 
    } 
     
    /** 
     * Checks if this MapFile has the indicated key. The membership test is 
     * performed using a Bloom filter, so the result has always non-zero 
     * probability of false positives. 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readFully, close
            byte[] body = null;
            if (entity != null) {
                try { 
                    if (entity.getContentLength() > 0) {
                        body = new byte[(int) entity.getContentLength()];
                        DataInputStream dis = new DataInputStream(entity.getContent());
                        try { 
                            dis.readFully(body);
                        } finally { 
                            try { 
                                dis.close();
                            } catch (IOException e) {
                                Log.e(TAG, "Unexpected IOException.", e);
                            } 
                        } 
                    } 
                } finally { 
                    if (entity != null) {
                        entity.consumeContent();
                    } 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readFully, readShort
	} 
 
	@Override 
	public void readData(DataInputStream data) throws IOException {
 
		super.readData(data);
 
		short length = data.readShort();
		byte[] compressed = new byte[length];
		data.readFully(compressed);
		this.nbttagcompound = CompressedStreamTools.decompress(compressed);
	} 
 
	public NBTTagCompound getTagCompound() { 
		return this.nbttagcompound;
	} 
 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readFully, readInt, readShort
 
	@Override 
	public void readData(DataInputStream data) throws IOException {
		super.readData(data);
 
		this.entityId = data.readInt();
		short length = data.readShort();
		byte[] compressed = new byte[length];
		data.readFully(compressed);
		this.tag = CompressedStreamTools.decompress(compressed);
	} 
 
	public int getEntityId() { 
		return entityId;
	} 
 
	public NBTTagCompound getTagCompound() { 
		return tag;
	} 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 DataInputStream Questions & Answers:

See Code Examples for Java 8 DataInputStream Methods: