ConvertToBigEndian(byte[] buffer, int startIndex, int bytesToConvert) { long ret = 0; for (int i=0; i < bytesToConvert; i++) { ret = unchecked((ret << 8) | buffer[startIndex+i]); } return ret; } 把一个byte[]转换成BigEndian。 第一个参数就是要转换的Byte[],第二个参数是从那一位开始转换,第三个参数是转换多少位
”FLASH写2进制文件默认按BigEndian编码”,这句话可能不完全准确。SWF Specification里有这么一段话: The SWF file format uses 8-bit, 16-bit, 32-bit, 64-bit, signed, and unsigned integer types. All integer values are stored in the SWF file by using little-endian byte order: the least significant byte is stored first, and the most significant byte is stored last, in the same way as the Intel x86 architecture. The bit order within bytes in the SWF file format is big-endian: the most significant bit is stored first, and the least significant bit is stored last.
我不知道flash的方法是什么作用你需要看一下你的文件内容是什么 如果是标准的字符如(abcdefg)
那么你需要使用 streamreader如果是二进制流才需要使用BinaryReader,文件存的是byte[]才用它
看来还是两边读写格式不匹配,估计只能自己重新写个读字符串的函数了
{
long ret = 0;
for (int i=0; i < bytesToConvert; i++)
{
ret = unchecked((ret << 8) | buffer[startIndex+i]);
}
return ret;
}
把一个byte[]转换成BigEndian。
第一个参数就是要转换的Byte[],第二个参数是从那一位开始转换,第三个参数是转换多少位
The SWF file format uses 8-bit, 16-bit, 32-bit, 64-bit, signed, and unsigned integer types. All
integer values are stored in the SWF file by using little-endian byte order: the least significant
byte is stored first, and the most significant byte is stored last, in the same way as the Intel x86
architecture. The bit order within bytes in the SWF file format is big-endian: the most
significant bit is stored first, and the least significant bit is stored last.