List<IntWritable> values = new ArrayList<IntWritable>();
Text key = new Text("key");
IntWritable val = new IntWritable(1);
for(int i = 0; i < 5; i++) {
data.add(new KVPair(key, val));
values.add(val);
}
IFile.Writer writer = new IFile.Writer(defaultConf, localFs, outputPath,
Text.class, IntWritable.class, codec, null, null);
writer.append(data.get(0).getKey(), data.get(0).getvalue()); //write first KV pair
writer.appendValues(values.subList(1, values.size()).iterator()); //add the rest here
Text lastKey = new Text("key3");
IntWritable lastVal = new IntWritable(10);
data.add(new KVPair(lastKey, lastVal));
writer.append(lastKey, lastVal);
writer.close();
readAndVerifyData(writer.getRawLength(), writer.getCompressedLength(), data, codec);