Codota Logo
LittleEndianDataInputStream.readFully
Code IndexAdd Codota to your IDE (free)

How to use
readFully
method
in
com.google.common.io.LittleEndianDataInputStream

Best Java code snippets using com.google.common.io.LittleEndianDataInputStream.readFully (Showing top 4 results out of 315)

  • Common ways to obtain LittleEndianDataInputStream
private void myMethod () {
LittleEndianDataInputStream l =
  • Codota IconInputStream in;new LittleEndianDataInputStream(in)
  • Smart code suggestions by Codota
}
origin: jorabin/KeePassJava2

  private static byte [] getByteArray(LittleEndianDataInputStream ledis) throws IOException {
    short fieldLength = ledis.readShort();
    byte [] value = new byte[fieldLength];
    ledis.readFully(value);
    return value;
  }
}
origin: jorabin/KeePassJava2

private static void checkStartBytes(KdbxHeader kdbxHeader, InputStream decryptedInputStream) throws IOException {
  LittleEndianDataInputStream ledis = new LittleEndianDataInputStream(decryptedInputStream);
  byte [] startBytes = new byte[32];
  ledis.readFully(startBytes);
  if (!Arrays.equals(startBytes, kdbxHeader.getStreamStartBytes())) {
    throw new IllegalStateException("Inconsistent stream start bytes. This usually means the credentials were wrong.");
  }
}
origin: yandex/clickhouse-jdbc

private byte[] readNextBlock() throws IOException {
  int read = stream.read();
  if (read < 0) return null;
  byte[] checksum = new byte[16];
  checksum[0] = (byte)read;
  // checksum - 16 bytes.
  dataWrapper.readFully(checksum, 1, 15);
  ClickHouseBlockChecksum expected = ClickHouseBlockChecksum.fromBytes(checksum);
  // header:
  // 1 byte - 0x82 (shows this is LZ4)
  int magic = dataWrapper.readUnsignedByte();
  if (magic != MAGIC) throw new IOException("Magic is not correct: " + magic);
  // 4 bytes - size of the compressed data including 9 bytes of the header
  int compressedSizeWithHeader = dataWrapper.readInt();
  // 4 bytes - size of uncompressed data
  int uncompressedSize = dataWrapper.readInt();
  int compressedSize = compressedSizeWithHeader - 9; //header
  byte[] block = new byte[compressedSize];
  // compressed data: compressed_size - 9 байт.
  dataWrapper.readFully(block);
  ClickHouseBlockChecksum real = ClickHouseBlockChecksum.calculateForBlock((byte)magic, compressedSizeWithHeader, uncompressedSize, block, compressedSize);
  if (!real.equals(expected)) {
    throw new IllegalArgumentException("Checksum doesn't match: corrupted data.");
  }
  byte[] decompressed = new byte[uncompressedSize];
  LZ4FastDecompressor decompressor = factory.fastDecompressor();
  decompressor.decompress(block, 0, decompressed, 0, uncompressedSize);
  return decompressed;
}
origin: ru.yandex.clickhouse/clickhouse-jdbc

private byte[] readNextBlock() throws IOException {
  int read = stream.read();
  if (read < 0) return null;
  byte[] checksum = new byte[16];
  checksum[0] = (byte)read;
  // checksum - 16 bytes.
  dataWrapper.readFully(checksum, 1, 15);
  ClickHouseBlockChecksum expected = ClickHouseBlockChecksum.fromBytes(checksum);
  // header:
  // 1 byte - 0x82 (shows this is LZ4)
  int magic = dataWrapper.readUnsignedByte();
  if (magic != MAGIC) throw new IOException("Magic is not correct: " + magic);
  // 4 bytes - size of the compressed data including 9 bytes of the header
  int compressedSizeWithHeader = dataWrapper.readInt();
  // 4 bytes - size of uncompressed data
  int uncompressedSize = dataWrapper.readInt();
  int compressedSize = compressedSizeWithHeader - 9; //header
  byte[] block = new byte[compressedSize];
  // compressed data: compressed_size - 9 байт.
  dataWrapper.readFully(block);
  ClickHouseBlockChecksum real = ClickHouseBlockChecksum.calculateForBlock((byte)magic, compressedSizeWithHeader, uncompressedSize, block, compressedSize);
  if (!real.equals(expected)) {
    throw new IllegalArgumentException("Checksum doesn't match: corrupted data.");
  }
  byte[] decompressed = new byte[uncompressedSize];
  LZ4FastDecompressor decompressor = factory.fastDecompressor();
  decompressor.decompress(block, 0, decompressed, 0, uncompressedSize);
  return decompressed;
}
com.google.common.ioLittleEndianDataInputStreamreadFully

Popular methods of LittleEndianDataInputStream

  • readInt
    Reads an integer as specified by DataInputStream#readInt(), except using little-endian byte order.
  • readLong
    Reads a long as specified by DataInputStream#readLong(), except using little-endian byte order.
  • <init>
    Creates a LittleEndianDataInputStream that wraps the given stream.
  • readUnsignedByte
  • readUnsignedShort
    Reads an unsigned short as specified by DataInputStream#readUnsignedShort(), except using little-end
  • readAndCheckByte
    Reads a byte from the input stream checking that the end of file (EOF) has not been encountered.
  • readByte
  • close
  • readDouble
    Reads a double as specified by DataInputStream#readDouble(), except using little-endian byte order.
  • readFloat
    Reads a float as specified by DataInputStream#readFloat(), except using little-endian byte order.
  • readShort
    Reads a short as specified by DataInputStream#readShort(), except using little-endian byte order.
  • read
  • readShort,
  • read,
  • readBoolean,
  • readUTF,
  • skip,
  • skipBytes

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • orElseThrow (Optional)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now