Index: Base64.java
===================================================================
--- Base64.java	(revision 4892)
+++ Base64.java	(working copy)
@@ -1060,7 +1060,7 @@
     
     
     /**
-     * A {@link Base64#InputStream} will read data from another
+     * A { InputStream} will read data from another
      * {@link java.io.InputStream}, given in the constructor,
      * and encode/decode to/from Base64 notation on the fly.
      *
@@ -1080,7 +1080,7 @@
         
         
         /**
-         * Constructs a {@link Base64#InputStream} in DECODE mode.
+         * Constructs a { Base64#InputStream} in DECODE mode.
          *
          * @param in the {@link java.io.InputStream} from which to read data.
          * @since 1.3
@@ -1092,7 +1092,7 @@
         
         
         /**
-         * Constructs a {@link Base64#InputStream} in
+         * Constructs a { Base64#InputStream} in
          * either ENCODE or DECODE mode.
          *
          * @param in the {@link java.io.InputStream} from which to read data.
@@ -1108,7 +1108,7 @@
         
         
         /**
-         * Constructs a {@link Base64#InputStream} in
+         * Constructs a { Base64#InputStream} in
          * either ENCODE or DECODE mode.
          *
          * @param in the {@link java.io.InputStream} from which to read data.
@@ -1297,7 +1297,7 @@
     
     
     /**
-     * A {@link Base64#OutputStream} will write data to another
+     * A { Base64#OutputStream} will write data to another
      * {@link java.io.OutputStream}, given in the constructor,
      * and encode/decode to/from Base64 notation on the fly.
      *
@@ -1316,7 +1316,7 @@
         
         
         /**
-         * Constructs a {@link Base64#OutputStream} in ENCODE mode.
+         * Constructs a {Base64#OutputStream} in ENCODE mode.
          *
          * @param out the {@link java.io.OutputStream} to which data will be written.
          * @since 1.3
@@ -1328,7 +1328,7 @@
         
         
         /**
-         * Constructs a {@link Base64#OutputStream} in
+         * Constructs a { Base64#OutputStream} in
          * either ENCODE or DECODE mode.
          *
          * @param out the {@link java.io.OutputStream} to which data will be written.
@@ -1344,7 +1344,7 @@
         
         
         /**
-         * Constructs a {@link Base64#OutputStream} in
+         * Constructs a { Base64#OutputStream} in
          * either ENCODE or DECODE mode.
          *
          * @param out the {@link java.io.OutputStream} to which data will be written.
Index: ByteBufferIterator.java
===================================================================
--- ByteBufferIterator.java	(revision 0)
+++ ByteBufferIterator.java	(revision 0)
@@ -0,0 +1,108 @@
+package org.systemsbiology.jrap.stax;
+import java.io.*;
+import java.nio.*;
+import java.nio.channels.*;
+import java.util.*;
+
+public class ByteBufferIterator implements Iterator
+{
+
+    private int INITIAL_BUFFERSIZE = 10000;
+    private int bufferSize = INITIAL_BUFFERSIZE;
+    private FileInputStream fis = null;
+    private FileChannel fc = null;
+    private String fPath;
+    private long fSize;
+    private ByteBuffer bb = null;
+    private long totBytesRead = 0;
+
+    public void setBufferSize (int b) {
+	      this.bufferSize = b;
+          //bb = ByteBuffer.allocate(bufferSize);
+    }
+
+    public int getBufferSize() {
+	      return this.bufferSize;
+    }
+
+    public long getFileSize() {
+       return this.fSize;
+    }
+
+    public String getPath() {
+       return this.fPath;
+    }
+
+    public long getFilePos() {
+       return totBytesRead;
+    }
+
+    public ByteBufferIterator(String fN) throws IOException {
+	   fPath = fN;
+       fis = new FileInputStream(fN);
+       fc = fis.getChannel();
+       fSize = fc.size();
+	}
+
+    public ByteBufferIterator(String fN, int buflen) throws Exception {
+	   fPath = fN;
+       fis = new FileInputStream(fN);
+       fc = fis.getChannel();
+       fSize = fc.size();
+       bufferSize = buflen;
+    }
+
+    public boolean hasNext() {
+	   return totBytesRead < fSize;
+    }
+/*
+    public ByteBuffer next() {
+       try {
+          if(bb == null) bb = ByteBuffer.allocate(bufferSize);
+          bb.rewind();
+		  int bytesRead = fc.read(bb);
+          if(bytesRead > 0){
+             totBytesRead += bytesRead;
+             bb.limit(bytesRead);
+          } else {
+  		     fis.close();
+          }
+          bb.rewind(); 
+          //System.out.println("read "+bytesRead+" bytes, current total is "+totBytesRead+"; and filesize is "+fSize);
+       } catch (Exception e) {
+	      System.err.println("Problem in ByteBufferIterator.next(): "+e);
+          e.printStackTrace();
+          return null;
+       }
+       return bb;
+    }
+*/
+    public ByteBuffer next() {
+        try {
+            //dhmay 20100223, fixing issue with small files in which you can't try to read the full buffer size
+            //on the last scan
+            long numBytesToRead = Math.min(bufferSize, fSize-totBytesRead);
+            bb = fc.map(FileChannel.MapMode.READ_ONLY, totBytesRead, numBytesToRead);
+            int bytesRead = bb.capacity();
+            if(bytesRead > 0){
+                totBytesRead += bytesRead;
+            } else {
+                fis.close();
+            }
+            bb.rewind();
+            //System.out.println("read "+bytesRead+" bytes, current total is "+totBytesRead+"; and filesize is "+fSize);
+        } catch (Exception e) {
+            System.err.println("Problem in ByteBufferIterator.next(): "+e);
+            e.printStackTrace();
+            return null;
+        }
+        return bb;
+    }
+
+    public void remove() {}
+
+    protected void finalize() throws Throwable {
+        try {fis.close();} catch (Throwable t) {};
+        super.finalize();
+    }
+ }
