FileDocCategorySizeDatePackage
ChannelTransfer.javaAPI DocExample1282Mon Apr 29 17:39:40 BST 2002com.ronsoft.books.nio.channels

ChannelTransfer

public 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
author
Ron Hitchens (ron@ronsoft.com)
version
$Id: ChannelTransfer.java,v 1.2 2002/04/30 00:39:41 ron Exp $

Fields Summary
Constructors Summary
Methods Summary
private static voidcatFiles(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 voidmain(java.lang.String[] argv)

		if (argv.length == 0) {
			System.err.println ("Usage: filename ...");
			return;
		}

		catFiles (Channels.newChannel (System.out), argv);