public void open(InputStream stream) { close(); if (stream != null) { // We need to explicitly cast to DataInput as otherwise the constructor is ambiguous. // We choose DataInput instead of InputStream as ExtDataInput wraps an InputStream in // a DataInputStream which is big-endian and ignores the little-endian behavior. m_reader = new ExtDataInput((DataInput) new LittleEndianDataInputStream(stream)); } }
private ARSCDecoder(InputStream arscStream, ResTable resTable, boolean storeFlagsOffsets, boolean keepBroken) { arscStream = mCountIn = new CountingInputStream(arscStream); if (storeFlagsOffsets) { mFlagsOffsets = new ArrayList<FlagsOffset>(); } else { mFlagsOffsets = null; } // We need to explicitly cast to DataInput as otherwise the constructor is ambiguous. // We choose DataInput instead of InputStream as ExtDataInput wraps an InputStream in // a DataInputStream which is big-endian and ignores the little-endian behavior. mIn = new ExtDataInput((DataInput) new LittleEndianDataInputStream(arscStream)); mResTable = resTable; mKeepBroken = keepBroken; }
public void testReadUnsignedShort_eof() throws IOException { byte[] buf = {23}; DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(buf)); try { in.readUnsignedShort(); fail(); } catch (EOFException expected) { } }
public void testReadUnsignedByte_eof() throws IOException { DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0])); try { in.readUnsignedByte(); fail(); } catch (EOFException expected) { } }
public void testReadFully() throws IOException { DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data)); byte[] b = new byte[data.length]; in.readFully(b); assertEquals(Bytes.asList(data), Bytes.asList(b)); }
public void testReadLine() throws IOException { DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data)); try { in.readLine(); fail(); } catch (UnsupportedOperationException expected) { assertThat(expected).hasMessageThat().isEqualTo("readLine is not supported"); } }
public void testSkipBytes() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos); /* Write out various test values NORMALLY */ out.write(new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); // 10 bytes of junk to skip initializeData(out); byte[] data = baos.toByteArray(); DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data)); int bytesSkipped = 0; while (bytesSkipped < 10) { bytesSkipped += in.skipBytes(10 - bytesSkipped); } /* Read in various values in LITTLE ENDIAN FORMAT */ byte[] b = new byte[2]; in.readFully(b); assertEquals(-100, b[0]); assertEquals(100, b[1]); assertTrue(in.readBoolean()); assertFalse(in.readBoolean()); } }
public void testReadLittleEndian() throws IOException { DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data)); /* Read in various values in LITTLE ENDIAN FORMAT */ byte[] b = new byte[2]; in.readFully(b); assertEquals(-100, b[0]); assertEquals(100, b[1]); assertEquals(true, in.readBoolean()); assertEquals(false, in.readBoolean()); assertEquals(100, in.readByte()); assertEquals(-100, in.readByte()); assertEquals(200, in.readUnsignedByte()); assertEquals('\u6100', in.readChar()); assertEquals(-12150, in.readShort()); assertEquals(20675, in.readUnsignedShort()); assertEquals(0xBEBAFECA, in.readInt()); assertEquals(0xBEBAFECAEFBEADDEL, in.readLong()); assertEquals("Herby Derby", in.readUTF()); assertEquals(0xBEBAFECA, Float.floatToIntBits(in.readFloat())); assertEquals(0xBEBAFECAEFBEADDEL, Double.doubleToLongBits(in.readDouble())); }
public SerializedKeyValueIterator(final InputStream input, final SmartSerializer<K> keySerializer, final SmartSerializer<V> valueSerializer) throws IOException { this.input = input; this.in = new LittleEndianDataInputStream(input); this.keySerializer = keySerializer; this.valueSerializer = valueSerializer; }
public TempFileIterator( Path tempPath, int tmpCount, Serializer<K> keySerializer ) throws IOException { this.tmpCount = tmpCount; this.keySerializer = keySerializer; in = new LittleEndianDataInputStream(new BufferedInputStream(Files.newInputStream(tempPath), 131072)); }
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") public InputStreamSliceInput(InputStream inputStream) { pushbackInputStream = new PushbackInputStream(inputStream); countingInputStream = new CountingInputStream(pushbackInputStream); dataInputStream = new LittleEndianDataInputStream(countingInputStream); }
public ClickHouseRowBinaryInputStream(InputStream is, TimeZone timeZone, ClickHouseProperties properties) { this.in = new LittleEndianDataInputStream(is); if (properties.isUseServerTimeZoneForDates()) { this.timeZone = timeZone; } else { this.timeZone = TimeZone.getDefault(); } }
public ClickHouseRowBinaryInputStream(InputStream is, TimeZone timeZone, ClickHouseProperties properties) { this.in = new LittleEndianDataInputStream(is); if (properties.isUseServerTimeZoneForDates()) { this.timeZone = timeZone; } else { this.timeZone = TimeZone.getDefault(); } }
public VectorIterator(File vectorsFile, long dimensions, boolean sparse) throws IOException { this.sparse = sparse; this.input = new LittleEndianDataInputStream(new FileInputStream(vectorsFile)); parseHeadline(this.input); if (this.dimensions != (int) dimensions) { throw new IOException("inconsistent number of dimensions."); } setCurrentContent(); }
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."); } }
public void testReadUnsignedByte_eof() throws IOException { DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0])); try { in.readUnsignedByte(); fail(); } catch (EOFException expected) { } }
private final void doStart() throws IOException { ReadUtil.readCheckType(m_stream, AXML_CHUNK_TYPE); /*chunk size*/ ReadUtil.readInt(m_stream); m_strings = StringBlock.read(new ExtDataInput((DataInput) new LittleEndianDataInputStream(m_stream))); ReadUtil.readCheckType(m_stream, RESOURCEIDS_CHUNK_TYPE); int chunkSize = ReadUtil.readInt(m_stream); if (chunkSize < 8 || (chunkSize % 4) != 0) { throw new IOException("Invalid resource ids size (" + chunkSize + ")."); } m_resourceIDs = ReadUtil.readIntArray(m_stream, chunkSize / 4 - 2); resetState(); }
@Override public void preProcess() throws IOException { fileHeader = new LibpcapGlobalHeader(getIs()); if(fileHeader.isSwapped()){ this.reader = new LittleEndianDataInputStream(getIs()); }else{ this.reader = new DataInputStream(getIs()); } }
public void testReadLine() throws IOException { DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data)); try { in.readLine(); fail(); } catch (UnsupportedOperationException expected) { assertThat(expected).hasMessage("readLine is not supported"); } }
public void testReadFully() throws IOException { DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data)); byte[] b = new byte[data.length]; in.readFully(b); assertEquals(Bytes.asList(data), Bytes.asList(b)); }