本文整理了Java中java.io.DataInputStream.mark()
方法的一些代码示例,展示了DataInputStream.mark()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataInputStream.mark()
方法的具体详情如下:
包路径:java.io.DataInputStream
类名称:DataInputStream
方法名:mark
暂无
代码示例来源:origin: netty/netty
@Override
public void mark(int readlimit) {
in.mark(readlimit);
}
代码示例来源:origin: apache/hbase
/**
* Parses an RegionInfo instance from the passed in stream.
* Presumes the RegionInfo was serialized to the stream with
* {@link #toDelimitedByteArray(RegionInfo)}.
* @param in
* @return An instance of RegionInfo.
* @throws IOException
*/
static RegionInfo parseFrom(final DataInputStream in) throws IOException {
// I need to be able to move back in the stream if this is not a pb
// serialization so I can do the Writable decoding instead.
int pblen = ProtobufUtil.lengthOfPBMagic();
byte [] pbuf = new byte[pblen];
if (in.markSupported()) { //read it with mark()
in.mark(pblen);
}
//assumption: if Writable serialization, it should be longer than pblen.
int read = in.read(pbuf);
if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen);
if (ProtobufUtil.isPBMagicPrefix(pbuf)) {
return ProtobufUtil.toRegionInfo(HBaseProtos.RegionInfo.parseDelimitedFrom(in));
} else {
throw new IOException("PB encoded RegionInfo expected");
}
}
代码示例来源:origin: redisson/redisson
@Override
public void mark(int readlimit) {
in.mark(readlimit);
}
代码示例来源:origin: apache/hbase
/**
* Parses an HRegionInfo instance from the passed in stream. Presumes the HRegionInfo was
* serialized to the stream with {@link #toDelimitedByteArray()}
* @param in
* @return An instance of HRegionInfo.
* @throws IOException
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
* Use {@link RegionInfo#parseFrom(DataInputStream)}.
*/
@Deprecated
@InterfaceAudience.Private
public static HRegionInfo parseFrom(final DataInputStream in) throws IOException {
// I need to be able to move back in the stream if this is not a pb serialization so I can
// do the Writable decoding instead.
int pblen = ProtobufUtil.lengthOfPBMagic();
byte [] pbuf = new byte[pblen];
if (in.markSupported()) { //read it with mark()
in.mark(pblen);
}
//assumption: if Writable serialization, it should be longer than pblen.
int read = in.read(pbuf);
if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen);
if (ProtobufUtil.isPBMagicPrefix(pbuf)) {
return convert(HBaseProtos.RegionInfo.parseDelimitedFrom(in));
} else {
throw new IOException("PB encoded HRegionInfo expected");
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public void mark(int readlimit) {
in.mark(readlimit);
}
代码示例来源:origin: apache/hbase
if (in.markSupported()) in.mark(pblen);
int read = in.read(pbuf);
if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen);
代码示例来源:origin: io.netty/netty
@Override
public void mark(int readlimit) {
in.mark(readlimit);
}
代码示例来源:origin: neo4j/neo4j
@Override
public byte peekByte() throws IOException
{
data.mark(1);
byte value = data.readByte();
data.reset();
return value;
}
}
代码示例来源:origin: apache/hive
protected boolean hasInput() throws IOException {
din.mark(1);
if (din.read() >= 0) {
din.reset();
return true;
}
return false;
}
代码示例来源:origin: apache/nifi
@Override
public SearchTerm<byte[]> nextTerm() throws IOException {
inStream.mark(1);
final int nextByte = inStream.read();
if (nextByte == -1) {
return null;
}
inStream.reset();
final int termLength = inStream.readInt();
final byte[] term = new byte[termLength];
inStream.readFully(term);
return new SearchTerm<>(term);
}
代码示例来源:origin: apache/zookeeper
public static boolean nextPacketIsAuth(DataInputStream din)
throws IOException {
din.mark(32);
BinaryInputArchive bia = new BinaryInputArchive(din);
boolean firstIsAuth = (bia.readLong("NO_TAG")
== QuorumAuth.QUORUM_AUTH_MAGIC_NUMBER);
din.reset();
return firstIsAuth;
}
}
代码示例来源:origin: apache/nifi
private SwapDeserializer createSwapDeserializer(final DataInputStream dis) throws IOException {
dis.mark(MAGIC_HEADER.length);
final byte[] magicHeader = new byte[MAGIC_HEADER.length];
try {
StreamUtils.fillBuffer(dis, magicHeader);
} catch (final EOFException eof) {
throw new IOException("Failed to read swap file because the file contained less than 4 bytes of data");
}
if (Arrays.equals(magicHeader, MAGIC_HEADER)) {
final String serializationName = dis.readUTF();
if (serializationName.equals(SchemaSwapDeserializer.getSerializationName())) {
return new SchemaSwapDeserializer();
}
throw new IOException("Cannot find a suitable Deserializer for swap file, written with Serialization Name '" + serializationName + "'");
} else {
// SimpleSwapDeserializer is old and did not write out a magic header.
dis.reset();
return new SimpleSwapDeserializer();
}
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
public static boolean nextPacketIsAuth(DataInputStream din)
throws IOException {
din.mark(32);
BinaryInputArchive bia = new BinaryInputArchive(din);
boolean firstIsAuth = (bia.readLong("NO_TAG")
== QuorumAuth.QUORUM_AUTH_MAGIC_NUMBER);
din.reset();
return firstIsAuth;
}
}
代码示例来源:origin: btraceio/btrace
public BTraceProbe createProbe(InputStream code, ArgsMap argsMap) {
BTraceProbe bp = null;
try (DataInputStream dis = new DataInputStream(code)) {
dis.mark(0);
int mgc = dis.readInt();
if (mgc == BTraceProbePersisted.MAGIC) {
BTraceProbePersisted bpp = new BTraceProbePersisted(this);
bpp.read(dis);
bp = bpp;
} else {
code.reset();
bp = new BTraceProbeNode(this, code);
}
} catch (IOException e) {
if (debug.isDebug()) {
debug.debug(e);
}
}
applyArgs(bp, argsMap);
return bp;
}
代码示例来源:origin: plutext/docx4j
/**
* Parses a PFB file into a PFBData object.
* @param in InputStream to load the PFB file from
* @return PFBData memory representation of the font
* @throws IOException In case of an I/O problem
*/
public PFBData parsePFB(InputStream in) throws IOException {
PFBData pfb = new PFBData();
BufferedInputStream bin = new BufferedInputStream(in);
DataInputStream din = new DataInputStream(bin);
din.mark(32);
int firstByte = din.readUnsignedByte();
din.reset();
if (firstByte == 128) {
pfb.setPFBFormat(PFBData.PFB_PC);
parsePCFormat(pfb, din);
} else {
pfb.setPFBFormat(PFBData.PFB_RAW);
parseRAWFormat(pfb, bin);
}
return pfb;
}
代码示例来源:origin: apache/activemq
try {
this.dataIn.mark(10);
int type = this.dataIn.read();
if (type == -1) {
代码示例来源:origin: apache/geode
try {
if (this.updateOK) {
this.dataIn.mark(BUFFER_SIZE);
代码示例来源:origin: apache/activemq
try {
this.dataIn.mark(10);
int type = this.dataIn.read();
if (type == -1) {
代码示例来源:origin: apache/activemq
initializeReading();
try {
this.dataIn.mark(33);
int type = this.dataIn.read();
if (type == -1) {
代码示例来源:origin: apache/activemq
try {
this.dataIn.mark(17);
int type = this.dataIn.read();
if (type == -1) {
内容来源于网络,如有侵权,请联系作者删除!