zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java 使用 NIO 进行文件合并输出详解编程语言

JAVA文件nio输出编程语言 使用 详解 进行
2023-06-13 09:20:29 时间
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();

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10573.html

cjavamac