当前位置: 首页>>代码示例>>Java>>正文


Java DataInputStream.readByte方法代码示例

本文整理汇总了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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CompressIndexes.java

示例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);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:22,代码来源:ServerConnectionInitializer.java

示例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;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:DTD.java

示例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);
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:34,代码来源:DHTUDPPacketData.java

示例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;
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:16,代码来源:TagType.java

示例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;
}
 
开发者ID:PanagiotisDrakatos,项目名称:T0rlib4j,代码行数:30,代码来源:Utilities.java

示例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();
	}
}
 
开发者ID:Elbehiry,项目名称:Pc-Control,代码行数:37,代码来源:RemoteItAction.java

示例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();
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:13,代码来源:NBSDecoder.java

示例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]);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:30,代码来源:ADC2Module.java

示例10: readPacket

import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
protected void readPacket(DataInputStream in) throws IOException {
	this.username = in.readUTF();
	this.primaryType = in.readByte();
}
 
开发者ID:ProjectK47,项目名称:Mafia,代码行数:6,代码来源:PacketChoosePrimary.java

示例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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:ZoneInfoFile.java

示例12: read

import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
public void read(DataInputStream stream) throws IOException{
	color = stream.readByte();
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:5,代码来源:Teleporter.java

示例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();
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:7,代码来源:LiquidBlock.java

示例14: read

import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
public void read(DataInputStream input) throws IOException {
    value = input.readByte();
}
 
开发者ID:OrigamiDream,项目名称:Leveled-Storage,代码行数:5,代码来源:ByteStorage.java

示例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();
	}
}
 
开发者ID:Detea,项目名称:PekaED,代码行数:6,代码来源:PK2Sprite.java


注:本文中的java.io.DataInputStream.readByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。