import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class NIOCat {
public static void main(String[] args) throws IOException {
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();
}
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。