ChannelTransferpublic class ChannelTransfer extends Object Test channel transfer. This is a very simplistic concatenation
program. It takes a list of file names as arguments, opens each
in turn and transfers (copies) their content to the given
WritableByteChannel (in this case, stdout).
Created April 2002 |
Methods Summary |
---|
private static void | catFiles(java.nio.channels.WritableByteChannel target, java.lang.String[] files)
for (int i = 0; i < files.length; i++) {
FileInputStream fis = new FileInputStream (files [i]);
FileChannel channel = fis.getChannel();
channel.transferTo (0, channel.size(), target);
channel.close();
fis.close();
}
| public static void | main(java.lang.String[] argv)
if (argv.length == 0) {
System.err.println ("Usage: filename ...");
return;
}
catFiles (Channels.newChannel (System.out), argv);
|
|