Java Code Examples for com.google.common.io.LittleEndianDataInputStream#readInt()
The following examples show how to use
com.google.common.io.LittleEndianDataInputStream#readInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KdbxSerializer.java From KeePassJava2 with Apache License 2.0 | 5 votes |
private static int getInt(LittleEndianDataInputStream ledis) throws IOException { short fieldLength = ledis.readShort(); if (fieldLength != 4) { throw new IllegalStateException("Int required but length was " + fieldLength); } return ledis.readInt(); }
Example 2
Source File: FileSerializationBenchmark.java From imhotep with Apache License 2.0 | 5 votes |
@Override public int[] deserialize(File file) throws IOException { LittleEndianDataInputStream is = new LittleEndianDataInputStream(new BufferedInputStream(new FileInputStream(file))); int[] ret = new int[(int)(file.length() / 4)]; for (int i = 0; i < ret.length; ++i) { ret[i] = is.readInt(); } return ret; }
Example 3
Source File: GuavaIOUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void whenWriteReadLittleEndian_thenCorrect() throws IOException { final int value = 100; final LittleEndianDataOutputStream writer = new LittleEndianDataOutputStream(new FileOutputStream("src/test/resources/test_le.txt")); writer.writeInt(value); writer.close(); final LittleEndianDataInputStream reader = new LittleEndianDataInputStream(new DataInputStream(new FileInputStream("src/test/resources/test_le.txt"))); final int result = reader.readInt(); reader.close(); assertEquals(value, result); }
Example 4
Source File: Util.java From SmartModInserter with GNU Lesser General Public License v3.0 | 4 votes |
public static String readString(LittleEndianDataInputStream objectInputStream) throws IOException { int size = objectInputStream.readInt(); byte read[] = new byte[size]; objectInputStream.read(read); return new String(read); }
Example 5
Source File: KdbxSerializer.java From KeePassJava2 with Apache License 2.0 | 2 votes |
/** * Read two lots of 4 bytes and verify that they satisfy the signature of a * kdbx file; * @param ledis an input stream * @return true if it looks like this is a kdbx file * @throws IOException on error */ private static boolean verifyMagicNumber(LittleEndianDataInputStream ledis) throws IOException { int sig1 = ledis.readInt(); int sig2 = ledis.readInt(); return sig1 == SIG1 && sig2 == SIG2; }
Example 6
Source File: KdbxSerializer.java From KeePassJava2 with Apache License 2.0 | 2 votes |
/** * Read 4 bytes and make sure they conform to expectations of file version * @param ledis an input stream * @return true if it looks like we understand this file version * @throws IOException on error */ private static boolean verifyFileVersion(LittleEndianDataInputStream ledis) throws IOException { return ((ledis.readInt() & FILE_VERSION_CRITICAL_MASK) <= (FILE_VERSION_32 & FILE_VERSION_CRITICAL_MASK)); }