从文件中读取4个字节,然后从RandomAccessFile中将其解释为UINT32。
//package com.nowjava; import java.io.IOException; import java.io.RandomAccessFile;/** from 时 代 J a v a 公 众 号 - N o w J a v a . c o m**/ public class Main { /** * Reads 4 bytes from file and interprets them as UINT32.<br> * * @param raf * file to read from. * @return UINT32 value * @throws IOException * on I/O Errors. */ public static long readUINT32(RandomAccessFile raf) throws IOException { long result = 0; for (int i = 0; i < 4; i++) { // Warning, always cast to long here. Otherwise it will be // shifted as int, which may produce a negative value, which will