Example usage for com.google.common.io LittleEndianDataInputStream skip

List of usage examples for com.google.common.io LittleEndianDataInputStream skip

Introduction

In this page you can find the example usage for com.google.common.io LittleEndianDataInputStream skip.

Prototype

public long skip(long n) throws IOException 

Source Link

Document

Skips over and discards n bytes of data from the input stream.

Usage

From source file:pw.simplyintricate.bitcoin.models.datastructures.NetworkAddress.java

public static NetworkAddress fromInputStream(LittleEndianDataInputStream reader, boolean readTime)
        throws IOException {
    int time = -1;
    if (readTime) {
        time = reader.readInt();/*  w ww .j  a v a  2  s .  c  o  m*/
    }

    long services = reader.readLong();
    reader.skip(12); // skip ipv6 support :(
    byte[] ipAddress = new byte[4];
    reader.read(ipAddress, 0, 4);
    short port = EndianUtils.swapShort(((short) reader.readUnsignedShort()));

    NetworkAddress networkAddress;
    if (readTime) {
        networkAddress = new NetworkAddress(UnsignedInteger.valueOf(services), ipAddress, port,
                UnsignedInteger.fromIntBits(time));
    } else {
        networkAddress = new NetworkAddress(UnsignedInteger.valueOf(services), ipAddress, port);
    }

    return networkAddress;
}