Java tutorial
//package com.java2s; //License from project: Creative Commons License import java.io.IOException; import java.io.RandomAccessFile; public class Main { /** * Reads 4 bytes and concatenates them into a String. * This pattern is used for ID's of various kinds. */ public static String read4Chars(RandomAccessFile raf) throws IOException { StringBuffer sbuf = new StringBuffer(4); for (int i = 0; i < 4; i++) { char ch = (char) raf.read(); sbuf.append(ch); } return sbuf.toString(); } }