FileDocCategorySizeDatePackage
NIOCat.javaAPI DocExample755Tue Feb 14 05:59:52 GMT 2006None

NIOCat

public class NIOCat extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


    if (args.length < 2) {
      System.err.println("Usage: java NIOCat inFile1 inFile2... outFile");
      return;
    }
    
    ByteBuffer[] buffers = new ByteBuffer[args.length-1];
    for (int i = 0; i < args.length-1; i++) {
      RandomAccessFile raf = new RandomAccessFile(args[i], "r");
      FileChannel channel = raf.getChannel();
      buffers[i] = channel.map(FileChannel.MapMode.READ_ONLY, 0, raf.length());
    }
    
    FileOutputStream outFile = new FileOutputStream(args[args.length-1]);
    FileChannel out = outFile.getChannel();
    out.write(buffers);
    out.close();