A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way.
A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream.

DataInputStream is not necessarily safe for multithreaded access. Thread safety is optional and is the responsibility of users of methods in this class.

Inheritance: FilterInputStream, DataInput
 public TCPImageFetcher(int teamNumber)
 {
   base.\u002Ector();
   TCPImageFetcher tcpImageFetcher = this;
   this.m_sock = (Socket) null;
   this.m_sockistream = (InputStream) null;
   this.m_imgBuffer = (byte[]) null;
   this.m_maxImgBufferSize = 0;
   this.m_baistream = (ByteArrayInputStream) null;
   this.m_daistream = (DataInputStream) null;
   this.m_initialized = false;
   this.m_address = (byte[]) null;
   int num1 = (int) (sbyte) (teamNumber / 100);
   int num2 = teamNumber;
   int num3 = 100;
   int num4 = -1;
   int num5 = num3 != num4 ? (int) (sbyte) (num2 % num3) : 0;
   byte[] numArray = new byte[4];
   int index1 = 0;
   int num6 = 10;
   numArray[index1] = (byte) num6;
   int index2 = 1;
   int num7 = num1;
   numArray[index2] = (byte) num7;
   int index3 = 2;
   int num8 = num5;
   numArray[index3] = (byte) num8;
   int index4 = 3;
   int num9 = 2;
   numArray[index4] = (byte) num9;
   this.m_address = numArray;
 }
Beispiel #2
0
        public static List readWatchableObjects(DataInputStream datainputstream)
        {
            ArrayList arraylist = null;
            for (byte byte0 = datainputstream.readByte(); byte0 != 127; byte0 = datainputstream.readByte())
            {
                if (arraylist == null)
                {
                    arraylist = new ArrayList();
                }
                int i = (byte0 & 0xe0) >> 5;
                int j = byte0 & 0x1f;
                WatchableObject watchableobject = null;
                switch (i)
                {
                    case 0: // '\0'
                        watchableobject = new WatchableObject(i, j, Byte.valueOf(datainputstream.readByte()));
                        break;

                    case 1: // '\001'
                        watchableobject = new WatchableObject(i, j, Short.valueOf(datainputstream.readShort()));
                        break;

                    case 2: // '\002'
                        watchableobject = new WatchableObject(i, j, Integer.valueOf(datainputstream.readInt()));
                        break;

                    case 3: // '\003'
                        watchableobject = new WatchableObject(i, j, Float.valueOf(datainputstream.readFloat()));
                        break;

                    case 4: // '\004'
                        watchableobject = new WatchableObject(i, j, datainputstream.readUTF());
                        break;

                    case 5: // '\005'
                        short word0 = datainputstream.readShort();
                        byte byte1 = datainputstream.readByte();
                        short word1 = datainputstream.readShort();
                        watchableobject = new WatchableObject(i, j, new ItemStack(word0, byte1, word1));

                        // fall through (not.. c#..)

                        int k2 = datainputstream.readInt();
                        int l2 = datainputstream.readInt();
                        int i12 = datainputstream.readInt();
                        watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k2, l2, i12));

                        break;
                    case 6: // '\006'
                        int k = datainputstream.readInt();
                        int l = datainputstream.readInt();
                        int i1 = datainputstream.readInt();
                        watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1));
                        break;
                }
                arraylist.add(watchableobject);
            }

            return arraylist;
        }
Beispiel #3
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     windowId = datainputstream.readByte();
     inventoryType = datainputstream.readByte();
     windowTitle = datainputstream.readUTF();
     slotsCount = datainputstream.readByte();
 }
Beispiel #4
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     motionX = datainputstream.readShort();
     motionY = datainputstream.readShort();
     motionZ = datainputstream.readShort();
 }
Beispiel #5
0
 public NetworkManager(Socket socket, string s, NetHandler nethandler)
 {
     sendQueueLock = new object();
     m_isRunning = true;
     readPackets = Collections.synchronizedList(new ArrayList());
     dataPackets = Collections.synchronizedList(new ArrayList());
     chunkDataPackets = Collections.synchronizedList(new ArrayList());
     m_isServerTerminating = false;
     isTerminating = false;
     terminationReason = "";
     timeSinceLastRead = 0;
     sendQueueByteLength = 0;
     chunkDataSendCounter = 0;
     field_20175_w = 50;
     networkSocket = socket;
     remoteSocketAddress = socket.getRemoteSocketAddress();
     netHandler = nethandler;
     socket.setTrafficClass(24);
     socketInputStream = new DataInputStream(socket.getInputStream());
     socketOutputStream = new DataOutputStream(socket.getOutputStream());
     readThread = new NetworkReaderThread(this, (new StringBuilder()).append(s).append(" read thread").toString());
     writeThread = new NetworkWriterThread(this,
                                           (new StringBuilder()).append(s).append(" write thread").toString());
     readThread.start();
     writeThread.start();
 }
Beispiel #6
0
 public virtual java.io.DataInputStream GetChunkDataInputStream(int i, int j)
 {
     lock (this)
     {
         if (OutOfBounds(i, j))
         {
             Debugln("READ", i, j, "out of bounds");
             return(null);
         }
         try
         {
             int k = GetOffset(i, j);
             if (k == 0)
             {
                 return(null);
             }
             int l  = k >> 8;
             int i1 = k & 0xff;
             if (l + i1 > sectorFree.Count)
             {
                 Debugln("READ", i, j, "invalid sector");
                 return(null);
             }
             dataFile.Seek(l * 4096);
             int j1 = dataFileIn.ReadInt();
             if (j1 > 4096 * i1)
             {
                 Debugln("READ", i, j, (new java.lang.StringBuilder()).Append("invalid length: ").
                         Append(j1).Append(" > 4096 * ").Append(i1).ToString());
                 return(null);
             }
             byte byte0 = dataFileIn.ReadByte();
             if (byte0 == 1)
             {
                 byte[] abyte0 = new byte[j1 - 1];
                 dataFileIn.Read(abyte0);
                 java.io.DataInputStream datainputstream = new java.io.DataInputStream(new GZipStream(new MemoryStream(abyte0), CompressionMode.Decompress));
                 return(datainputstream);
             }
             if (byte0 == 2)
             {
                 byte[] abyte1 = new byte[j1 - 1];
                 dataFileIn.Read(abyte1);
                 java.io.DataInputStream datainputstream1 = new java.io.DataInputStream(new DeflateStream(new MemoryStream(abyte1), CompressionMode.Decompress));
                 return(datainputstream1);
             }
             else
             {
                 Debugln("READ", i, j, (new java.lang.StringBuilder()).Append("unknown version ").
                         Append(byte0).ToString());
                 return(null);
             }
         }
         catch (System.IO.IOException)
         {
             Debugln("READ", i, j, "exception");
         }
         return(null);
     }
 }
 public override void readPacketData(DataInputStream datainputstream)
 {
     xPosition = datainputstream.readDouble();
     yPosition = datainputstream.readDouble();
     stance = datainputstream.readDouble();
     zPosition = datainputstream.readDouble();
     base.readPacketData(datainputstream);
 }
 private void init()
 {
   this.m_sock = new Socket(InetAddress.getByAddress(this.m_address), 1180);
   this.m_sock.setSoTimeout(3000);
   this.m_sockistream = this.m_sock.getInputStream();
   this.m_daistream = new DataInputStream(this.m_sockistream);
   this.m_initialized = true;
 }
Beispiel #9
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     protocolVersion = datainputstream.readInt();
     username = datainputstream.readUTF();
     password = datainputstream.readUTF();
     mapSeed = datainputstream.readLong();
     dimension = datainputstream.readByte();
 }
Beispiel #10
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.read();
     zPosition = datainputstream.readInt();
     type = datainputstream.read();
     metadata = datainputstream.read();
 }
Beispiel #11
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     xLocation = datainputstream.readInt();
     yLocation = datainputstream.readShort();
     zLocation = datainputstream.readInt();
     instrumentType = datainputstream.read();
     pitch = datainputstream.read();
 }
Beispiel #12
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     field_22041_a = datainputstream.readInt();
     field_22042_e = datainputstream.readByte();
     field_22040_b = datainputstream.readInt();
     field_22044_c = datainputstream.readByte();
     field_22043_d = datainputstream.readInt();
 }
 public override object readValue(DataInputStream dis)
 {
   int length = dis.readUnsignedByte();
   object[] objArray = new object[length];
   for (int index = 0; index < length; ++index)
     objArray[index] = this.elementType.readValue(dis);
   return (object) objArray;
 }
Beispiel #14
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     type = datainputstream.readByte();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
 }
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
     yaw = (byte) datainputstream.read();
     pitch = (byte) datainputstream.read();
 }
 public override void readPacketData(DataInputStream datainputstream)
 {
     base.readPacketData(datainputstream);
     xPosition = datainputstream.readByte();
     yPosition = datainputstream.readByte();
     zPosition = datainputstream.readByte();
     yaw = datainputstream.readByte();
     pitch = datainputstream.readByte();
 }
Beispiel #17
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     field_22035_a = datainputstream.readFloat();
     field_22034_b = datainputstream.readFloat();
     field_22037_e = datainputstream.readFloat();
     field_22036_f = datainputstream.readFloat();
     field_22039_c = datainputstream.readBoolean();
     field_22038_d = datainputstream.readBoolean();
 }
Beispiel #18
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     type = datainputstream.readByte();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
     yaw = datainputstream.readByte();
     pitch = datainputstream.readByte();
     receivedMetadata = DataWatcher.readWatchableObjects(datainputstream);
 }
Beispiel #19
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readShort();
     zPosition = datainputstream.readInt();
     signLines = new string[4];
     for (int i = 0; i < 4; i++)
     {
         signLines[i] = datainputstream.readUTF();
     }
 }
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     name = datainputstream.readUTF();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
     rotation = datainputstream.readByte();
     pitch = datainputstream.readByte();
     currentItem = datainputstream.readShort();
 }
 public NetworkTableConnection(IOStream ios, NetworkTableEntryTypeManager ntetm)
 {
   base.\u002Ector();
   NetworkTableConnection networkTableConnection = this;
   this.WRITE_LOCK = (object) new Object();
   this.__\u003C\u003Estream = ios;
   this.typeManager = ntetm;
   BufferedInputStream.__\u003Cclinit\u003E();
   this.@is = new DataInputStream((InputStream) new BufferedInputStream(ios.getInputStream()));
   this.os = new DataOutputStream((OutputStream) new BufferedOutputStream(ios.getOutputStream()));
   this.isValid = true;
 }
Beispiel #22
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     itemID = datainputstream.readShort();
     count = datainputstream.readByte();
     itemDamage = datainputstream.readShort();
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.readInt();
     zPosition = datainputstream.readInt();
     rotation = datainputstream.readByte();
     pitch = datainputstream.readByte();
     roll = datainputstream.readByte();
 }
Beispiel #23
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     windowId = datainputstream.readByte();
     short word0 = datainputstream.readShort();
     itemStack = new ItemStack[word0];
     for (int i = 0; i < word0; i++)
     {
         short word1 = datainputstream.readShort();
         if (word1 >= 0)
         {
             byte byte0 = datainputstream.readByte();
             short word2 = datainputstream.readShort();
             itemStack[i] = new ItemStack(word1, byte0, word2);
         }
     }
 }
        public override void readPacketData(DataInputStream datainputstream)
        {
            xPosition = datainputstream.readInt();
            zPosition = datainputstream.readInt();
            size = datainputstream.readShort() & 0xffff;
            coordinateArray = new short[size];
            typeArray = new byte[size];
            metadataArray = new byte[size];
            for (int i = 0; i < size; i++)
            {
                coordinateArray[i] = datainputstream.readShort();
            }

            datainputstream.readFully(typeArray);
            datainputstream.readFully(metadataArray);
        }
Beispiel #25
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     window_Id = datainputstream.readByte();
     inventorySlot = datainputstream.readShort();
     mouseClick = datainputstream.readByte();
     action = datainputstream.readShort();
     short word0 = datainputstream.readShort();
     if (word0 >= 0)
     {
         byte byte0 = datainputstream.readByte();
         short word1 = datainputstream.readShort();
         itemStack = new ItemStack(word0, byte0, word1);
     }
     else
     {
         itemStack = null;
     }
 }
Beispiel #26
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     xPosition = datainputstream.readInt();
     yPosition = datainputstream.read();
     zPosition = datainputstream.readInt();
     direction = datainputstream.read();
     short word0 = datainputstream.readShort();
     if (word0 >= 0)
     {
         byte byte0 = datainputstream.readByte();
         short word1 = datainputstream.readShort();
         itemStack = new ItemStack(word0, byte0, word1);
     }
     else
     {
         itemStack = null;
     }
 }
Beispiel #27
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     explosionX = datainputstream.readDouble();
     explosionY = datainputstream.readDouble();
     explosionZ = datainputstream.readDouble();
     explosionSize = datainputstream.readFloat();
     int i = datainputstream.readInt();
     destroyedBlockPositions = new HashSet();
     var j = (int) explosionX;
     var k = (int) explosionY;
     var l = (int) explosionZ;
     for (int i1 = 0; i1 < i; i1++)
     {
         int j1 = datainputstream.readByte() + j;
         int k1 = datainputstream.readByte() + k;
         int l1 = datainputstream.readByte() + l;
         destroyedBlockPositions.add(new ChunkPosition(j1, k1, l1));
     }
 }
Beispiel #28
0
 public void func_22091_b()
 {
     try
     {
         var file = new File(field_22099_b, "session.lock");
         var datainputstream = new DataInputStream(new FileInputStream(file));
         try
         {
             if (datainputstream.readLong() != field_22100_d)
             {
                 throw new MinecraftException("The save is being accessed from another location, aborting");
             }
         }
         finally
         {
             datainputstream.close();
         }
     }
     catch (IOException)
     {
         throw new MinecraftException("Failed to check session lock, aborting");
     }
 }
 internal BlockDataInputStream(InputStream @in)
 {
     this.@in = new PeekInputStream(@in);
     din = new DataInputStream(this);
 }
Beispiel #30
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     username = datainputstream.readUTF();
 }
Beispiel #31
0
 public override void readPacketData(DataInputStream datainputstream)
 {
     entityId = datainputstream.readInt();
     field_21018_b = DataWatcher.readWatchableObjects(datainputstream);
 }
        /// <summary>
        /// Reads from the
        /// stream <code>in</code> a representation
        /// of a Unicode  character string encoded in
        /// <a href="DataInput.html#modified-utf-8">modified UTF-8</a> format;
        /// this string of characters is then returned as a <code>String</code>.
        /// The details of the modified UTF-8 representation
        /// are  exactly the same as for the <code>readUTF</code>
        /// method of <code>DataInput</code>.
        /// </summary>
        /// <param name="in">   a data input stream. </param>
        /// <returns>     a Unicode string. </returns>
        /// <exception cref="EOFException">            if the input stream reaches the end
        ///               before all the bytes. </exception>
        /// <exception cref="IOException">   the stream has been closed and the contained
        ///             input stream does not support reading after close, or
        ///             another I/O error occurs. </exception>
        /// <exception cref="UTFDataFormatException">  if the bytes do not represent a
        ///               valid modified UTF-8 encoding of a Unicode string. </exception>
        /// <seealso cref=        java.io.DataInputStream#readUnsignedShort() </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public final static String readUTF(DataInput in) throws IOException
        public static String ReadUTF(DataInput @in)
        {
            int utflen = @in.ReadUnsignedShort();

            sbyte[] bytearr = null;
            char[]  chararr = null;
            if (@in is DataInputStream)
            {
                DataInputStream dis = (DataInputStream)@in;
                if (dis.Bytearr.Length < utflen)
                {
                    dis.Bytearr = new sbyte[utflen * 2];
                    dis.Chararr = new char[utflen * 2];
                }
                chararr = dis.Chararr;
                bytearr = dis.Bytearr;
            }
            else
            {
                bytearr = new sbyte[utflen];
                chararr = new char[utflen];
            }

            int c, char2, char3;
            int count         = 0;
            int chararr_count = 0;

            @in.ReadFully(bytearr, 0, utflen);

            while (count < utflen)
            {
                c = (int)bytearr[count] & 0xff;
                if (c > 127)
                {
                    break;
                }
                count++;
                chararr[chararr_count++] = (char)c;
            }

            while (count < utflen)
            {
                c = (int)bytearr[count] & 0xff;
                switch (c >> 4)
                {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                    /* 0xxxxxxx*/
                    count++;
                    chararr[chararr_count++] = (char)c;
                    break;

                case 12:
                case 13:
                    /* 110x xxxx   10xx xxxx*/
                    count += 2;
                    if (count > utflen)
                    {
                        throw new UTFDataFormatException("malformed input: partial character at end");
                    }
                    char2 = (int)bytearr[count - 1];
                    if ((char2 & 0xC0) != 0x80)
                    {
                        throw new UTFDataFormatException("malformed input around byte " + count);
                    }
                    chararr[chararr_count++] = (char)(((c & 0x1F) << 6) | (char2 & 0x3F));
                    break;

                case 14:
                    /* 1110 xxxx  10xx xxxx  10xx xxxx */
                    count += 3;
                    if (count > utflen)
                    {
                        throw new UTFDataFormatException("malformed input: partial character at end");
                    }
                    char2 = (int)bytearr[count - 2];
                    char3 = (int)bytearr[count - 1];
                    if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
                    {
                        throw new UTFDataFormatException("malformed input around byte " + (count - 1));
                    }
                    chararr[chararr_count++] = (char)(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
                    break;

                default:
                    /* 10xx xxxx,  1111 xxxx */
                    throw new UTFDataFormatException("malformed input around byte " + count);
                }
            }
            // The number of chars produced may be less than utflen
            return(new String(chararr, 0, chararr_count));
        }