//CFBufferedReader // Purpose: // Since ColdFusion automatically turns "null" Strings into empty strings, // it is necessary to extend BufferedReader so that we can detect // the null string returned from readLine(). // // Use: // CFBufferedReader works exactly like java.io.BufferedReader, // but adds an isEOF() method to indicate whether the last call // to readLine detected the end of the file. // // Author: // Daryl Banttari (Macromedia) // // Copyright: (c)2001 Macromedia // Feel free to use this for any purpose, with or without inclusion // of this copyright notice, so long as you agree to hold Macromedia // completely harmless for any use of this code. // We are using several classes from java.io, // so import everything under java.io: import java.io.*; // Define this class as a subclass of java.io.BufferedReader public class CFBufferedReader extends java.io.BufferedReader { // variable to hold the EOF status of the last read // default to false; we'll assume you're not at eof if // we haven't read anything yet private boolean eof = false; // our class constructors will simply pass the arguments // through to our superclass, BufferedReader: public CFBufferedReader(Reader in, int sz) { // "super" is an alias to the superclass. // calling super() in this fashion actually // invokes the superclass' constructor method. super(in, sz); } public CFBufferedReader(Reader in) { super(in); } // here we extend the readLine method: public String readLine() throws java.io.IOException { String curLine; // call the "real" readLine() method from the superclass curLine = super.readLine(); // now set eof to "is curline null?" // note that there are two equals signs between "curLine" and "null" eof = (curLine == null); // return curline to the caller "as is" return curLine; } public boolean isEOF() { // simply return the current value if the eof variable return eof; } public void close() throws java.io.IOException { //simply call the superclass function to close file super.close(); } }