List of usage examples for java.io DataInput readFully
void readFully(byte b[]) throws IOException;
From source file:org.ambud.marauder.source.ids.pcap.layer3.IPv6.java
@Override public void decode(DataInput di, EtherFrame parent) throws IOException { this.parent = parent; byte[] tempBytes = new byte[4]; di.readFully(tempBytes); this.version = (byte) ((tempBytes[0] >> 4) & 0xff); this.trafficClass = (byte) ((tempBytes[0] << 4) | ((tempBytes[1] >> 4) & 0xff)); this.flowLbl = (byte) ((((int) (tempBytes[1] << 4) & 0xffff) << 16) | (((short) tempBytes[2] << 8) & 0xff) | (tempBytes[3] & 0xff)); this.payloadLength = EtherFrame.readShort(di); this.nextHdr = di.readByte(); this.hopLimit = di.readByte(); di.readFully(this.srcIP); di.readFully(this.dstIP); decodeNextLayer(di);/* w w w . jav a 2 s . c o m*/ }
From source file:org.apache.accumulo.core.client.BatchWriterConfig.java
@Override public void readFields(DataInput in) throws IOException { byte[] len = new byte[7]; in.readFully(len); String strLen = new String(len, UTF_8); if (!strLen.endsWith("#")) throw new IllegalStateException("length was not encoded correctly"); byte[] bytes = new byte[Integer.parseInt(strLen.substring(strLen.lastIndexOf(' ') + 1, strLen.length() - 1), 36)];//from w ww . j a v a 2 s. c om in.readFully(bytes); String strFields = new String(bytes, UTF_8); String[] fields = StringUtils.split(strFields, '\\', ','); for (String field : fields) { String[] keyValue = StringUtils.split(field, '\\', '='); String key = keyValue[0]; String value = keyValue[1]; if ("maxMemory".equals(key)) { maxMemory = Long.valueOf(value); } else if ("maxLatency".equals(key)) { maxLatency = Long.valueOf(value); } else if ("maxWriteThreads".equals(key)) { maxWriteThreads = Integer.valueOf(value); } else if ("timeout".equals(key)) { timeout = Long.valueOf(value); } else if ("durability".equals(key)) { durability = DurabilityImpl.fromString(value); } else { /* ignore any other properties */ } } }
From source file:org.apache.accumulo.core.client.impl.AuthenticationTokenIdentifier.java
@Override public void readFields(DataInput in) throws IOException { int length = in.readInt(); if (length > 0) { ThriftMessageUtil msgUtil = new ThriftMessageUtil(); byte[] serialized = new byte[length]; in.readFully(serialized); impl = new TAuthenticationTokenIdentifier(); msgUtil.deserialize(serialized, impl); }/*from w w w . j a v a 2 s. co m*/ }
From source file:org.apache.accumulo.server.security.delegation.AuthenticationKey.java
@Override public void readFields(DataInput in) throws IOException { int length = WritableUtils.readVInt(in); if (0 == length) { return;/* ww w . jav a 2s .c o m*/ } ThriftMessageUtil util = new ThriftMessageUtil(); byte[] bytes = new byte[length]; in.readFully(bytes); authKey = util.deserialize(bytes, new TAuthenticationKey()); secret = AuthenticationTokenSecretManager.createSecretKey(authKey.getSecret()); }
From source file:org.apache.carbondata.core.metadata.blocklet.BlockletInfo.java
/** * Deserialize datachunks as well for older versions like V1 and V2 *///from ww w . j a v a2 s . c om private void readChunkInfoForOlderVersions(DataInput input) throws IOException { short dimChunksSize = input.readShort(); dimensionColumnChunk = new ArrayList<>(dimChunksSize); for (int i = 0; i < dimChunksSize; i++) { byte[] bytes = new byte[input.readInt()]; input.readFully(bytes); dimensionColumnChunk.add(deserializeDataChunk(bytes)); } short msrChunksSize = input.readShort(); measureColumnChunk = new ArrayList<>(msrChunksSize); for (int i = 0; i < msrChunksSize; i++) { byte[] bytes = new byte[input.readInt()]; input.readFully(bytes); measureColumnChunk.add(deserializeDataChunk(bytes)); } }
From source file:org.apache.cassandra.utils.ByteBufferUtil.java
private static ByteBuffer read(DataInput in, int length) throws IOException { ByteBuffer array;/*from w w w . j av a2 s . c o m*/ if (in instanceof FileDataInput) { array = ((FileDataInput) in).readBytes(length); } else { byte[] buff = new byte[length]; in.readFully(buff); array = ByteBuffer.wrap(buff); } return array; }
From source file:org.apache.drill.exec.cache.CachedVectorContainer.java
@Override public void read(DataInput input) throws IOException { int len = input.readInt(); this.data = new byte[len]; input.readFully(data); }
From source file:org.apache.eagle.alert.engine.serialization.impl.JavaObjectSerializer.java
@Override public Object deserialize(DataInput dataInput) throws IOException { int len = dataInput.readInt(); byte[] bytes = new byte[len]; dataInput.readFully(bytes); return SerializationUtils.deserialize(bytes); }
From source file:org.apache.fop.render.pdf.ImageRawJPEGAdapter.java
/** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { InputStream in = getImage().createInputStream(); in = ImageUtil.decorateMarkSupported(in); try {// www . j ava 2s.c o m JPEGFile jpeg = new JPEGFile(in); DataInput din = jpeg.getDataInput(); //Copy the whole JPEG file except: // - the ICC profile //TODO Thumbnails could safely be skipped, too. //TODO Metadata (XMP, IPTC, EXIF) could safely be skipped, too. while (true) { int reclen; int segID = jpeg.readMarkerSegment(); switch (segID) { case JPEGConstants.SOI: out.write(0xFF); out.write(segID); break; case JPEGConstants.EOI: case JPEGConstants.SOS: out.write(0xFF); out.write(segID); IOUtils.copy(in, out); //Just copy the rest! return; /* case JPEGConstants.APP1: //Metadata case JPEGConstants.APPD: jpeg.skipCurrentMarkerSegment(); break;*/ case JPEGConstants.APP2: //ICC (see ICC1V42.pdf) boolean skipICCProfile = false; in.mark(16); try { reclen = jpeg.readSegmentLength(); // Check for ICC profile byte[] iccString = new byte[11]; din.readFully(iccString); din.skipBytes(1); //string terminator (null byte) if ("ICC_PROFILE".equals(new String(iccString, "US-ASCII"))) { skipICCProfile = (this.image.getICCProfile() != null); } } finally { in.reset(); } if (skipICCProfile) { //ICC profile is skipped as it is already embedded as a PDF object jpeg.skipCurrentMarkerSegment(); break; } default: out.write(0xFF); out.write(segID); reclen = jpeg.readSegmentLength(); //write short out.write((reclen >>> 8) & 0xFF); out.write((reclen >>> 0) & 0xFF); int left = reclen - 2; byte[] buf = new byte[2048]; while (left > 0) { int part = Math.min(buf.length, left); din.readFully(buf, 0, part); out.write(buf, 0, part); left -= part; } } } } finally { IOUtils.closeQuietly(in); } }
From source file:org.apache.geode.internal.cache.Oplog.java
private void readOplogMagicSeqRecord(DataInput dis, File f, OPLOG_TYPE type) throws IOException { byte[] seq = new byte[OPLOG_TYPE.getLen()]; dis.readFully(seq); for (int i = 0; i < OPLOG_TYPE.getLen(); i++) { if (seq[i] != type.getBytes()[i]) { if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) { logger.trace(LogMarker.PERSIST_RECOVERY, "oplog magic code mismatched at byte:{}, value:{}", (i + 1), seq[i]); }/* w ww . jav a2s . co m*/ throw new DiskAccessException("Invalid oplog (" + type.name() + ") file provided: " + f, getParent()); } } if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < OPLOG_TYPE.getLen(); i++) { sb.append(" ").append(seq[i]); } logger.trace(LogMarker.PERSIST_RECOVERY, "oplog magic code: {}", sb); } readEndOfRecord(dis); }