本文整理了Java中java.io.DataInputStream.readShort()
方法的一些代码示例,展示了DataInputStream.readShort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataInputStream.readShort()
方法的具体详情如下:
包路径:java.io.DataInputStream
类名称:DataInputStream
方法名:readShort
[英]See the general contract of the readShort
method of DataInput
.
Bytes for this operation are read from the contained input stream.
[中]参见readShort
方法DataInput
的总合同。
此操作的字节从包含的输入流中读取。
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Read an integer of this type from the given input stream
*/
public int read(DataInputStream in) throws IOException {
switch (this) {
case INT8:
return in.readByte();
case INT16:
return in.readShort();
case INT32:
return in.readInt();
default:
throw new RuntimeException("Unknown itype: " + this);
}
}
代码示例来源:origin: voldemort/voldemort
private void checkException(DataInputStream inputStream) throws IOException {
short retCode = inputStream.readShort();
if(retCode != 0) {
String error = inputStream.readUTF();
throw mapper.getError(retCode, error);
}
}
代码示例来源:origin: apache/geode
private long readCompactValue() throws IOException {
long v = dataIn.readByte();
if (v < MIN_1BYTE_COMPACT_VALUE) {
if (v == COMPACT_VALUE_2_TOKEN) {
v = dataIn.readShort();
} else {
int bytesToRead = ((byte) v - COMPACT_VALUE_2_TOKEN) + 2;
v = dataIn.readByte(); // note the first byte will be a signed byte.
bytesToRead--;
while (bytesToRead > 0) {
v <<= 8;
v |= dataIn.readUnsignedByte();
bytesToRead--;
}
}
}
return v;
}
代码示例来源:origin: HotswapProjects/HotswapAgent
DataInputStream dis = new DataInputStream(
new ByteArrayInputStream(bytes));
dis.readLong(); // skip header and class version
int cpcnt = (dis.readShort() & 0xffff) - 1;
int[] classes = new int[cpcnt];
String[] strings = new String[cpcnt];
int t = dis.read();
if (t == 7)
classes[i] = dis.readShort() & 0xffff;
else if (t == 1)
strings[i] = dis.readUTF();
else if (t == 5 || t == 6) {
dis.readLong();
i++;
} else if (t == 8)
dis.readShort();
else
dis.readInt();
dis.readShort(); // skip access flags
return strings[classes[(dis.readShort() & 0xffff) - 1] - 1].replace('/',
'.');
代码示例来源:origin: apache/kylin
public static AppendDictSlice deserializeFrom(DataInput in) throws IOException {
byte[] headPartial = new byte[HEAD_MAGIC.length + Short.SIZE / Byte.SIZE + Integer.SIZE / Byte.SIZE];
in.readFully(headPartial);
if (BytesUtil.compareBytes(HEAD_MAGIC, 0, headPartial, 0, HEAD_MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(headPartial, HEAD_SIZE_I, headPartial.length - HEAD_SIZE_I));
int headSize = headIn.readShort();
int bodyLen = headIn.readInt();
headIn.close();
byte[] all = new byte[headSize + bodyLen];
System.arraycopy(headPartial, 0, all, 0, headPartial.length);
in.readFully(all, headPartial.length, all.length - headPartial.length);
return new AppendDictSlice(all);
}
代码示例来源:origin: stackoverflow.com
Socket socket = ......;
DataInputStream dis = new DataInputStream(socket.getInputStream());
short f1 = dis.readShort();
long f2 = dis.readLong();
sort f3 = dis.readShort();
代码示例来源:origin: stackoverflow.com
InputStream is = new FileInputStream (file);
BufferedInputStream bis = new BufferedInputStream (is, 8000);
DataInputStream dis = new DataInputStream (bis); // Create a DataInputStream to read the audio data from the saved file
int i = 0; // Read the file into the "music" array
while (dis.available() > 0)
{
music[i] = dis.readShort(); // This assignment does not reverse the order
i++;
}
dis.close(); // Close the input stream
代码示例来源:origin: wildfly/wildfly
DataInputStream dis=null;
try {
dis=new DataInputStream(input);
version=dis.readShort();
byte flags=dis.readByte();
代码示例来源:origin: stackoverflow.com
public String[] loadText(String resName) throws IOException {
String[] text;
InputStream in = getClass().getResourceAsStream(resName);
try {
DataInputStream din = new DataInputStream(in);
int size = din.readShort();
text = new String[size];
for (int i = 0; i < size; i++) {
text[i] = din.readUTF();
}
} finally {
in.close();
}
return text;
}
代码示例来源:origin: robovm/robovm
int size = input.readInt();
Class<?> arrayClass = classDesc.forClass();
Class<?> componentType = arrayClass.getComponentType();
int[] intArray = (int[]) result;
for (int i = 0; i < size; i++) {
intArray[i] = input.readInt();
short[] shortArray = (short[]) result;
for (int i = 0; i < size; i++) {
shortArray[i] = input.readShort();
long[] longArray = (long[]) result;
for (int i = 0; i < size; i++) {
longArray[i] = input.readLong();
代码示例来源:origin: robovm/robovm
short numFields = input.readShort();
ObjectStreamField[] fields = new ObjectStreamField[numFields];
char typecode = (char) input.readByte();
String fieldName = input.readUTF();
boolean isPrimType = ObjectStreamClass.isPrimitiveType(typecode);
String classSig;
代码示例来源:origin: freenet/fred
private ClientMetadata(DataInputStream dis) throws MetadataParseException, IOException {
int magic = dis.readInt();
if(magic != MAGIC)
throw new MetadataParseException("Bad magic value in ClientMetadata");
short version = dis.readShort();
if(version != VERSION)
throw new MetadataParseException("Unrecognised version "+version+" in ClientMetadata");
boolean hasMIMEType = dis.readBoolean();
if(hasMIMEType)
mimeType = dis.readUTF();
else
mimeType = null;
}
代码示例来源:origin: org.apache.hadoop/hadoop-hdfs
private void processINodeFileAttributes(DataInputStream in, ImageVisitor v,
String parentName) throws IOException {
final String pathName = readINodePath(in, parentName);
v.visit(ImageElement.INODE_PATH, pathName);
processPermission(in, v);
v.visit(ImageElement.MODIFICATION_TIME, formatDate(in.readLong()));
if(NameNodeLayoutVersion.supports(Feature.FILE_ACCESS_TIME, imageVersion)) {
v.visit(ImageElement.ACCESS_TIME, formatDate(in.readLong()));
}
v.visit(ImageElement.REPLICATION, in.readShort());
v.visit(ImageElement.BLOCK_SIZE, in.readLong());
}
代码示例来源:origin: com.bbossgroups.rpc/bboss-rpc
public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException {
type=in.readByte();
id=in.readLong();
rsp_expected=in.readBoolean();
corrId=in.readShort();
}
代码示例来源:origin: apache/kylin
DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(trieBytes, MAGIC_SIZE_I, trieBytes.length - MAGIC_SIZE_I));
this.headSize = headIn.readShort();
this.bodyLen = headIn.readInt();
this.sizeChildOffset = headIn.read();
this.sizeNoValuesBeneath = headIn.read();
this.baseId = headIn.readShort();
this.maxValueLength = headIn.readShort();
if (maxValueLength < 0) {
throw new IllegalStateException("maxValueLength is negative (" + maxValueLength
String converterName = headIn.readUTF();
if (converterName.isEmpty() == false)
setConverterByName(converterName);
代码示例来源:origin: apache/kylin
@Override
public void readFields(DataInput in) throws IOException {
byte[] headPartial = new byte[MAGIC.length + Short.SIZE + Integer.SIZE];
in.readFully(headPartial);
if (BytesUtil.compareBytes(MAGIC, 0, headPartial, 0, MAGIC.length) != 0)
throw new IllegalArgumentException("Wrong file type (magic does not match)");
DataInputStream headIn = new DataInputStream(//
new ByteArrayInputStream(headPartial, MAGIC_SIZE_I, headPartial.length - MAGIC_SIZE_I));
int headSize = headIn.readShort();
int bodyLen = headIn.readInt();
headIn.close();
byte[] all = new byte[headSize + bodyLen];
System.arraycopy(headPartial, 0, all, 0, headPartial.length);
in.readFully(all, headPartial.length, all.length - headPartial.length);
init(all);
}
代码示例来源:origin: stackoverflow.com
DataInputStream r = new DataInputStream(socket.getInputStream());
r.readLong();
r.readShort();
代码示例来源:origin: apache/geode
private void readResourceInstanceCreateToken(boolean initialize) throws IOException {
int resourceInstId = dataIn.readInt();
int resourceTypeId = dataIn.readInt();
case BYTE_CODE:
case CHAR_CODE:
instBits[i] = dataIn.readByte();
break;
case WCHAR_CODE:
break;
case SHORT_CODE:
instBits[i] = dataIn.readShort();
break;
case INT_CODE:
代码示例来源:origin: marytts/marytts
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buf));
quantizedResidual = new byte[residualLength];
for (int i = 0; i < lpcOrder; i++) {
quantizedCoeffs[i] = dis.readShort();
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
DataInputStream dis = new DataInputStream(new BufferedInputStream(in));
dis.readShort();
short cMapLength = flipEndian(dis.readShort());
dis.readShort();
dis.readShort();
int width = flipEndian(dis.readShort());
int height = flipEndian(dis.readShort());
data[1] = dis.readByte();
data[0] = dis.readByte();
rawData[rawDataIndex++] = (byte) (int) (getBitsAsByte(data, 1, 5) * scalar);
rawData[rawDataIndex++] = (byte) (int) (getBitsAsByte(data, 6, 5) * scalar);
blue = dis.readByte();
green = dis.readByte();
red = dis.readByte();
int index = flipEndian(dis.readShort());
if (index >= cMapEntries.length || index < 0) {
throw new IOException("TGA: Invalid color map entry referenced: " + index);
内容来源于网络,如有侵权,请联系作者删除!