示例#1
0
        /*
         * public static float readJavaFloat(BinaryReader br)
         * {
         *  byte[] data = br.ReadBytes(4);
         *  float ret = BitConverter.ToSingle(data, 0);//应为a在b中其实字节为0,故第二个参数
         *  return ret;
         * }
         */

        /// <summary>
        /// 读取byte数组
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>
        public static byte[] readJavaByteArray(BinaryReader br)
        {
            short count = br.ReadInt16();

            count = XLReverseTools.reverseShort(count);

            byte[] data = br.ReadBytes(count);
            return(data);
        }
示例#2
0
        /// <summary>
        /// 读取一个java存的utf字符串
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>
        public static string readJavaUTF(BinaryReader br)
        {
            short count = br.ReadInt16();

            count = XLReverseTools.reverseShort(count);

            byte[] data = br.ReadBytes(count);
            string str  = Encoding.UTF8.GetString(data, 0, data.Length);

            return(str);
        }
示例#3
0
        /// <summary>
        /// 读取int32数组
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>
        public static int[] readJavaInt32Array(BinaryReader br)
        {
            short count = br.ReadInt16();

            count = XLReverseTools.reverseShort(count);

            int[] data = new int[count];
            for (int i = 0; i < count; i++)
            {
                data[i] = br.ReadInt32();
            }
            return(data);
        }
示例#4
0
        /// <summary>
        /// 读取string数组
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>
        public static string[] readJavaStringArray(BinaryReader br)
        {
            short count = br.ReadInt16();

            count = XLReverseTools.reverseShort(count);

            string[] data = new string[count];
            for (int i = 0; i < count; i++)
            {
                data[i] = readJavaUTF(br);
            }
            return(data);
        }
示例#5
0
        /// <summary>
        /// 读取float数组
        /// </summary>
        /// <param name="br"></param>
        /// <returns></returns>
        public static float[] readJavaFloatArray(BinaryReader br)
        {
            short count = br.ReadInt16();

            count = XLReverseTools.reverseShort(count);

            float[] data = new float[count];
            for (int i = 0; i < count; i++)
            {
                data[i] = readJavaFloat(br);
            }
            return(data);
        }