protected static void createRandomFile(Directory dir,String name,int size,byte[] segId) throws IOException {
  Random rnd=random();
  try (IndexOutput os=dir.createOutput(name,newIOContext(random()))){
    CodecUtil.writeIndexHeader(os,"Foo",0,segId,"suffix");
    for (int i=0; i < size; i++) {
      byte b=(byte)rnd.nextInt(256);
      os.writeByte(b);
    }
    CodecUtil.writeFooter(os);
  }
 }

protected static void createRandomFile ( Directory dir , String name , int size , byte [ ] segId ) throws IOException { Random rnd = random ( ) ; try ( IndexOutput os = dir . createOutput ( name , newIOContext ( random ( ) ) ) ) { CodecUtil . writeIndexHeader ( os , "Foo" , 0 , segId , "suffix" ) ; for ( int i = 0 ; i < size ; i ++ ) { byte b = ( byte ) rnd . nextInt ( 256 ) ; os . writeByte ( b ) ; } CodecUtil . writeFooter ( os ) ; } }
creates a file of the specified size with random data .
