List of usage examples for com.google.common.io LittleEndianDataInputStream readLong
@Override public long readLong() throws IOException
From source file:pw.simplyintricate.bitcoin.models.datastructures.BlockVersion.java
public static BlockVersion fromInputStream(LittleEndianDataInputStream reader) throws IOException { int version = reader.readInt(); long services = reader.readLong(); long timestamp = reader.readLong(); NetworkAddress receivingNetworkAddress = NetworkAddress.fromInputStream(reader); NetworkAddress emittingNetworkAddress = NetworkAddress.fromInputStream(reader); byte[] nonce = new byte[8]; reader.read(nonce, 0, nonce.length); VariableString userAgent = VariableString.fromInputStream(reader); int startingHeight = reader.readInt(); BlockVersion blockVersion = new BlockVersion(version, UnsignedInteger.valueOf(services), timestamp, receivingNetworkAddress, emittingNetworkAddress, nonce, userAgent, startingHeight); return blockVersion; }
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 . java2s . 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; }
From source file:org.linguafranca.pwdb.kdbx.stream_3_1.KdbxSerializer.java
private static long getLong(LittleEndianDataInputStream ledis) throws IOException { short fieldLength = ledis.readShort(); if (fieldLength != 8) { throw new IllegalStateException("Long required but length was " + fieldLength); }/*from w ww. j a va 2s.c o m*/ return ledis.readLong(); }
From source file:pw.simplyintricate.bitcoin.models.datastructures.VariableInteger.java
public static VariableInteger fromInputStream(LittleEndianDataInputStream reader) throws IOException { byte determiningSize = reader.readByte(); UnsignedInteger value;/* w w w . j a v a 2 s . c om*/ if (determiningSize < 0xfd) { value = UnsignedInteger.fromIntBits(determiningSize); } else if (determiningSize <= 0xffff) { int followUpValue = reader.readUnsignedShort(); value = UnsignedInteger.fromIntBits(followUpValue); } else if (determiningSize <= 0xffffffff) { int followUpValue = reader.readInt(); value = UnsignedInteger.valueOf(followUpValue); } else { long followUpValue = reader.readLong(); value = UnsignedInteger.valueOf(followUpValue); } VariableInteger variableInteger = new VariableInteger(value); return variableInteger; }
From source file:xyz.kuori.timeseries.TimeSeries.java
public int load(File archive) { FileInputStream fin = null;/*w ww .j a v a2s . co m*/ try { fin = new FileInputStream(archive); } catch (Exception e) { init(0); return (-1); } int record_count = (int) (archive.length() / 16); init(record_count); LittleEndianDataInputStream in = new LittleEndianDataInputStream(fin); try { for (int i = 0; i < record_count; i++) { timestamps[i] = in.readLong(); values[i] = in.readDouble(); } } catch (Exception e) { init(0); return (-1); } return (record_count); }
From source file:com.google.devtools.build.android.AndroidCompiledDataDeserializer.java
private void readResourceTable(LittleEndianDataInputStream resourceTableStream, KeyValueConsumers consumers) throws IOException { long alignedSize = resourceTableStream.readLong(); Preconditions.checkArgument(alignedSize <= Integer.MAX_VALUE); byte[] tableBytes = new byte[(int) alignedSize]; resourceTableStream.read(tableBytes, 0, (int) alignedSize); ResourceTable resourceTable = ResourceTable.parseFrom(tableBytes); readPackages(consumers, resourceTable); }