我需要从quicktime文件中读取一个无符号的int,并将其写回另一个quicktime文件。
目前,我将无符号整数读入到一个长整型中,但在写回它时,我从未设法将4字节中的确切数字写回为无符号整数。long具有我需要回写的正确值。(例如3289763894或370500)我甚至不能读写一个小于Integer.MAX_VALUE的数字(例如2997)。
我使用以下方法写回值
public void writeUInt32(long uint32,DataOutputStream stream) throws IOException {
writeUInt16((int) (uint32 & 0xffff0000) >> 16,stream);
writeUInt16((int) uint32 & 0x0000ffff,stream);
}
public void writeUInt16(int uint16,DataOutputStream stream) throws IOException {
writeUInt8(uint16 >> 8, stream);
writeUInt8(uint16, stream);
}
public void writeUInt8(int uint8,DataOutputStream stream) throws IOException {
stream.write(uint8 & 0xFF);
}任何帮助都将不胜感激。
发布于 2011-09-22 17:51:45
如果您只想读取、存储和重写它,那么您可以只使用int。更通用的是:只要你不解释比特,你就可以只读、存储和写入它们,而不需要关心比特的预期解释。
https://stackoverflow.com/questions/7512298
复制相似问题