Code example for Random

0
import org.junit.Test; 
 
public class TestSequenceFileSync { 
  private static final int NUMRECORDS = 2000;
  private static final int RECORDSIZE = 80;
  private static final Random rand = new Random();
 
  private final static String REC_FMT = "%d RECORDID %d : ";
 
 
  private static void forOffset(SequenceFile.Reader reader,
      IntWritable key, Text val, int iter, long off, int expectedRecord)
      throws IOException { 
    val.clear();
    reader.sync(off);
    reader.next(key, val);
    assertEquals(key.get(), expectedRecord);
    final String test = String.format(REC_FMT, expectedRecord, expectedRecord);
    assertEquals("Invalid value " + val, 0, val.find(test, 0));
  }