public static void main(String[] args) {
    String arg[] = {"-o", "file:/c:/foo.wav", "file:/c:/1.mp3", "file:/c:/1.wav"};
    args = arg;
    Vector<String> inputURL = new Vector<String>();
    String outputURL = null;

    if (args.length == 0) {
      prUsage();
    }

    // Parse the arguments.
    int i = 0;
    while (i < args.length) {

      if (args[i].equals("-o")) {
        i++;
        if (i >= args.length) prUsage();
        outputURL = args[i];
      } else {
        inputURL.addElement(args[i]);
      }
      i++;
    }

    if (inputURL.size() == 0) {
      System.err.println("No input url is specified");
      prUsage();
    }

    if (outputURL == null) {
      System.err.println("No output url is specified");
      prUsage();
    }

    // Generate the input and output media locators.
    MediaLocator iml[] = new MediaLocator[inputURL.size()];
    MediaLocator oml;

    for (i = 0; i < inputURL.size(); i++) {
      if ((iml[i] = createMediaLocator(inputURL.elementAt(i))) == null) {
        System.err.println("Cannot build media locator from: " + inputURL);
        System.exit(0);
      }
    }

    if ((oml = createMediaLocator(outputURL)) == null) {
      System.err.println("Cannot build media locator from: " + outputURL);
      System.exit(0);
    }

    FilesConcator concat = new FilesConcator();

    if (!concat.doIt(iml, oml)) {
      System.err.println("Failed to concatenate the inputs");
    }

    System.exit(0);
  }
 /** Controller Listener. */
 @Override
 public void controllerUpdate(ControllerEvent evt) {
   if (evt instanceof ControllerErrorEvent) {
     System.err.println("Failed to concatenate the files.");
     System.exit(-1);
   } else if (evt instanceof EndOfMediaEvent) {
     evt.getSourceController().close();
   }
 }
  /** Create a media locator from the given string. */
  @SuppressWarnings("unused")
  static MediaLocator createMediaLocator(String url) {
    MediaLocator ml;

    if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null) {
      return ml;
    }

    if (url.startsWith(File.separator)) {
      if ((ml = new MediaLocator("file:" + url)) != null) {
        return ml;
      }
    } else {
      String file = "file:" + System.getProperty("user.dir") + File.separator + url;
      if ((ml = new MediaLocator(file)) != null) {
        return ml;
      }
    }

    return null;
  }
 static void prUsage() {
   System.err.println("Usage: java Concat -o <output> <input> ...");
   System.err.println("     <output>: input URL or file name");
   System.err.println("     <input>: output URL or file name");
   System.exit(0);
 }