本文整理匯總了Java中java.io.DataInputStream.readByte方法的典型用法代碼示例。如果您正苦於以下問題:Java DataInputStream.readByte方法的具體用法?Java DataInputStream.readByte怎麽用?Java DataInputStream.readByte使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.DataInputStream
的用法示例。
在下文中一共展示了DataInputStream.readByte方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readInt
import java.io.DataInputStream; //導入方法依賴的package包/類
public static int readInt(DataInputStream cr) throws IOException {
// Get header byte.
byte header = cr.readByte();
// Determine size.
int size = getHeaderLength(header);
// Prepare result.
int result = getHeaderValue(header);
// For each value byte
for (int i = 1; i < size; i++) {
// Merge byte value.
result <<= Byte.SIZE;
result |= cr.readByte() & 0xFF;
}
return result;
}
示例2: initialConnect
import java.io.DataInputStream; //導入方法依賴的package包/類
private static void initialConnect(Socket javaSocket, NetJavaSocketImpl gdxSocket) throws Exception {
javaSocket.setSoTimeout(TIMEOUT);
DataInputStream dataInputStream = new DataInputStream(javaSocket.getInputStream());
byte b = dataInputStream.readByte();
DataOutputStream dataOutputStream = new DataOutputStream(javaSocket.getOutputStream());
dataOutputStream.writeInt(Branding.VERSION_MAJOR);
dataOutputStream.writeInt(Branding.VERSION_MINOR);
dataOutputStream.writeInt(Branding.VERSION_POINT);
dataOutputStream.writeInt(Branding.VERSION_BUILD);
dataOutputStream.writeUTF(Branding.VERSION_HASH);
switch (b) {
case 0:
connect(javaSocket, gdxSocket, dataOutputStream, dataInputStream);
return;
case 1:
ping(javaSocket, gdxSocket, dataOutputStream, dataInputStream);
return;
default:
throw new IOException("Unrecognised connection code " + b);
}
}
示例3: readAttributeList
import java.io.DataInputStream; //導入方法依賴的package包/類
private AttributeList readAttributeList(DataInputStream in, String[] names)
throws IOException {
AttributeList result = null;
for (int num = in.readByte(); num > 0; --num) {
short nameId = in.readShort();
int type = in.readByte();
int modifier = in.readByte();
short valueId = in.readShort();
String value = (valueId == -1) ? null : names[valueId];
Vector<String> values = null;
short numValues = in.readShort();
if (numValues > 0) {
values = new Vector<String>(numValues);
for (int i = 0; i < numValues; i++) {
values.addElement(names[in.readShort()]);
}
}
result = new AttributeList(names[nameId], type, modifier, value,
values, result);
// We reverse the order of the linked list by doing this, but
// that order isn't important.
}
return result;
}
示例4: DHTUDPPacketData
import java.io.DataInputStream; //導入方法依賴的package包/類
protected
DHTUDPPacketData(
DHTUDPPacketNetworkHandler network_handler,
DataInputStream is,
long con_id,
int trans_id )
throws IOException
{
super( network_handler, is, DHTUDPPacketHelper.ACT_DATA, con_id, trans_id );
packet_type = is.readByte();
transfer_key = DHTUDPUtils.deserialiseByteArray( is, 64 );
int max_key_size;
if ( getProtocolVersion() >= DHTTransportUDP.PROTOCOL_VERSION_REPLICATION_CONTROL ){
max_key_size = 255;
}else{
max_key_size = 64;
}
key = DHTUDPUtils.deserialiseByteArray( is, max_key_size );
start_position = is.readInt();
length = is.readInt();
total_length = is.readInt();
data = DHTUDPUtils.deserialiseByteArray( is, 65535 );
super.postDeserialise(is);
}
示例5: read
import java.io.DataInputStream; //導入方法依賴的package包/類
public Object read(DataInputStream in) throws IOException
{
Compound compound = new Compound();
while(true)
{
int id = in.readByte();
if(id == 0)
break;
compound.put(in.readUTF(), types.get(id).read(in));
}
return compound;
}
示例6: socks4aSocketConnection
import java.io.DataInputStream; //導入方法依賴的package包/類
public static Socket socks4aSocketConnection(String networkHost, int networkPort, String socksHost, int socksPort)
throws IOException {
Socket socket = new Socket();
socket.setSoTimeout(READ_TIMEOUT_MILLISECONDS);
SocketAddress socksAddress = new InetSocketAddress(socksHost, socksPort);
socket.connect(socksAddress, CONNECT_TIMEOUT_MILLISECONDS);
DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
outputStream.write((byte) 0x04);
outputStream.write((byte) 0x01);
outputStream.writeShort((short) networkPort);
outputStream.writeInt(0x01);
outputStream.write((byte) 0x00);
outputStream.write(networkHost.getBytes());
outputStream.write((byte) 0x00);
DataInputStream inputStream = new DataInputStream(socket.getInputStream());
byte firstByte = inputStream.readByte();
byte secondByte = inputStream.readByte();
if (firstByte != (byte) 0x00 || secondByte != (byte) 0x5a) {
socket.close();
throw new IOException("SOCKS4a connect failed, got " + firstByte + " - " + secondByte +
", but expected 0x00 - 0x5a");
}
inputStream.readShort();
inputStream.readInt();
return socket;
}
示例7: parse
import java.io.DataInputStream; //導入方法依賴的package包/類
public static RemoteItAction parse(DataInputStream dis) throws IOException
{
// This method shouldn't be called in the Client anymore. It's for the
// Server portion only
byte type = dis.readByte();
switch (type)
{
case MOUSE_MOVE:
return MouseMoveAction.parse(dis);
case MOUSE_CLICK:
return MouseClickAction.parse(dis);
case MOUSE_WHEEL:
return MouseWheelAction.parse(dis);
case KEYBOARD:
return KeyboardAction.parse(dis);
case AUTHENTIFICATION:
return AuthentificationAction.parse(dis);
case AUTHENTIFICATION_RESPONSE:
return AuthentificationResponseAction.parse(dis);
case SCREEN_CAPTURE_REQUEST:
return ScreenCaptureRequestAction.parse(dis);
case SCREEN_CAPTURE_RESPONSE:
return ScreenCaptureResponseAction.parse(dis);
case FILE_EXPLORE_REQUEST:
return FileExploreRequestAction.parse(dis);
case FILE_EXPLORE_RESPONSE:
return FileExploreResponseAction.parse(dis);
case COMBINATIONS:
return Combinations.parse(dis);
case COMBINATION:
return Combination.parse(dis);
default:
throw new ProtocolException();
}
}
示例8: readString
import java.io.DataInputStream; //導入方法依賴的package包/類
private static String readString(DataInputStream dis) throws IOException {
int length = readInt(dis);
StringBuilder sb = new StringBuilder(length);
for (; length > 0; --length) {
char c = (char) dis.readByte();
if (c == (char) 0x0D) {
c = ' ';
}
sb.append(c);
}
return sb.toString();
}
示例9: readDrawOptionsBlock
import java.io.DataInputStream; //導入方法依賴的package包/類
private void readDrawOptionsBlock(DataInputStream in) throws IOException {
ADC2Utils.readBlockHeader(in, "Draw Options");
@SuppressWarnings("unused")
boolean showHexSides = in.readByte() != 0;
@SuppressWarnings("unused")
boolean showHexLines = in.readByte() != 0;
@SuppressWarnings("unused")
boolean showPlaceNames = in.readByte() != 0;
int pieceOptionFlags = in.readUnsignedByte();
@SuppressWarnings("unused")
boolean showPieces = (pieceOptionFlags & 0x1) > 0;
@SuppressWarnings("unused")
boolean showMarkers = (pieceOptionFlags & 0x2) == 0;
/*
* First three bytes give symbols per hex for the three zoomlevels.
* 1 = 1 (inside hex)
* 4 = 4 per hex
* 101 = 1 (inside hex) & overlay stack on pieces
* 104 = 4 per hex & overlay stack on pieces
* 200 = 1 (centered)
* 201 = 1 (centered) & overlay stack on pieces
* all other values are completely invalid.
*
* The purpose of the last byte in this block is unknown.
*/
in.readFully(new byte[4]);
}
示例10: readPacket
import java.io.DataInputStream; //導入方法依賴的package包/類
@Override
protected void readPacket(DataInputStream in) throws IOException {
this.username = in.readUTF();
this.primaryType = in.readByte();
}
示例11: load
import java.io.DataInputStream; //導入方法依賴的package包/類
/**
* Loads the rules from a DateInputStream
*
* @param dis the DateInputStream to load, not null
* @throws Exception if an error occurs
*/
private static void load(DataInputStream dis) throws ClassNotFoundException, IOException {
if (dis.readByte() != 1) {
throw new StreamCorruptedException("File format not recognised");
}
// group
String groupId = dis.readUTF();
if ("TZDB".equals(groupId) == false) {
throw new StreamCorruptedException("File format not recognised");
}
// versions, only keep the last one
int versionCount = dis.readShort();
for (int i = 0; i < versionCount; i++) {
versionId = dis.readUTF();
}
// regions
int regionCount = dis.readShort();
String[] regionArray = new String[regionCount];
for (int i = 0; i < regionCount; i++) {
regionArray[i] = dis.readUTF();
}
// rules
int ruleCount = dis.readShort();
ruleArray = new byte[ruleCount][];
for (int i = 0; i < ruleCount; i++) {
byte[] bytes = new byte[dis.readShort()];
dis.readFully(bytes);
ruleArray[i] = bytes;
}
// link version-region-rules, only keep the last version, if more than one
for (int i = 0; i < versionCount; i++) {
regionCount = dis.readShort();
regions = new String[regionCount];
indices = new int[regionCount];
for (int j = 0; j < regionCount; j++) {
regions[j] = regionArray[dis.readShort()];
indices[j] = dis.readShort();
}
}
// remove the following ids from the map, they
// are exclued from the "old" ZoneInfo
zones.remove("ROC");
for (int i = 0; i < versionCount; i++) {
int aliasCount = dis.readShort();
aliases.clear();
for (int j = 0; j < aliasCount; j++) {
String alias = regionArray[dis.readShort()];
String region = regionArray[dis.readShort()];
aliases.put(alias, region);
}
}
// old us time-zone names
addOldMapping();
}
示例12: read
import java.io.DataInputStream; //導入方法依賴的package包/類
@Override
public void read(DataInputStream stream) throws IOException{
color = stream.readByte();
}
示例13: read
import java.io.DataInputStream; //導入方法依賴的package包/類
@Override
public void read(DataInputStream stream) throws IOException{
byte id = stream.readByte();
liquid = id == -1 ? null : Liquid.getByID(id);
liquidAmount = stream.readByte();
}
示例14: read
import java.io.DataInputStream; //導入方法依賴的package包/類
@Override
public void read(DataInputStream input) throws IOException {
value = input.readByte();
}
示例15: readAmount
import java.io.DataInputStream; //導入方法依賴的package包/類
private void readAmount(char[] array, DataInputStream dis) throws IOException {
for (int i = 0; i < array.length; i++) {
array[i] = (char) dis.readByte();
}
}