FileDocCategorySizeDatePackage
RootsChannel.javaAPI DocExample737Mon Feb 13 14:30:20 GMT 2006None

RootsChannel

public class RootsChannel extends Object

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

  
         

    // Put 1001 roots into a ByteBuffer via a double view buffer
    ByteBuffer data = ByteBuffer.allocate(SIZE_OF_DOUBLE * LENGTH);
    DoubleBuffer roots = data.asDoubleBuffer();
    while (roots.hasRemaining()) {
      roots.put(Math.sqrt(roots.position()));
    }
    
    // Open a channel to the file where we'll store the data
    FileOutputStream fout = new FileOutputStream("roots.dat");
    FileChannel outChannel = fout.getChannel();
    outChannel.write(data);
    outChannel.close();