MapFile { public static void main(String[] args) throws Exception { String usage = "Usage: MapFile inFile outFile"; if (args.length != 2) { System.err.println(usage); System.exit(-1); } String in = args[0]; String out = args[1]; Configuration conf = new Configuration(); FileSystem fs = FileSystem.getLocal(conf); MapFile.Reader reader = null; MapFile.Writer writer = null; try { reader = new MapFile.Reader(fs, in, conf); writer = new MapFile.Writer(conf, fs, out, reader.getKeyClass().asSubclass(WritableComparable.class), reader.getValueClass()); WritableComparable key = ReflectionUtils.newInstance(reader.getKeyClass() .asSubclass(WritableComparable.class), conf); Writable value = ReflectionUtils.newInstance(reader.getValueClass() .asSubclass(Writable.class), conf); while (reader.next(key, value)) writer.append(key, value); } finally { IOUtils.cleanup(LOG, writer, reader); } } protected  MapFile(); static void rename(FileSystem fs, String oldName, String newName); static void delete(FileSystem fs, String name); static long fix(FileSystem fs, Path dir,
                         Class<? extends Writable> keyClass,
                         Class<? extends Writable> valueClass, boolean dryrun,
                         Configuration conf); static void main(String[] args); static final String INDEX_FILE_NAME; static final String DATA_FILE_NAME; }
@Test public void testMainMethodMapFile() { String inFile = "mainMethodMapFile.mapfile"; String path = new Path(TEST_DIR, inFile).toString(); String[] args = { path, path }; MapFile.Writer writer = null; try { writer = createWriter(inFile, IntWritable.class, Text.class); writer.append(new IntWritable(1), new Text("test_text1")); writer.append(new IntWritable(2), new Text("test_text2")); writer.close(); MapFile.main(args); } catch (Exception ex) { fail("testMainMethodMapFile error !!!"); } finally { IOUtils.cleanup(null, writer); } }