import java.io.*; import com.google.common.hash.*; import com.google.common.io.Files; import org.marc4j.*; import org.marc4j.marc.Record; public class split { public static void main(String[] args) throws Exception { long StartTime = System.currentTimeMillis(); //Default values for arguments int NRecords = 250; String OutputPath = "./out/"; //Incorrect number of arguments supplied if(args.length!=5) { System.err.println("USAGE: java split [-n records_per_file] [-o output_path] input.xml"); System.err.println("DEFAULT: [-n 200] [-o ./out/]"); return; } //read arguments for(int i=0; i < args.length; i+=2) { if(args[i].equals("-n")) NRecords = Integer.parseInt(args[i+1]); else if(args[i].equals("-o")) OutputPath = args[i+1]; } InputStream in; try{ in = new FileInputStream(args[args.length-1]); } catch(Exception e){ System.err.println("Input file doesn't exist"); return; } MarcXmlReader reader = new MarcXmlReader(in); String TempFilename = OutputPath + "/temp.xml"; File f; int RecordCount = 0; while(reader.hasNext()) { f = new File(TempFilename); MarcWriter writer = new MarcXmlWriter(new FileOutputStream(f),true); Record record; //Write segment of records to file for(int i=0; (i