home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch13 / nff / CommentStripperInputStream.java < prev    next >
Text File  |  1996-11-27  |  726b  |  32 lines

  1. // Comment-stripping input
  2.  
  3. // Written by Bernie Roehl, November 1996
  4.  
  5. package nff;
  6.  
  7. import java.io.*;
  8.  
  9. public class CommentStripperInputStream extends FilterInputStream {
  10.  
  11.     DataInputStream input;
  12.  
  13.     public CommentStripperInputStream(DataInputStream in) {
  14.         super(in);
  15.         input = in;
  16.     }
  17.  
  18.     public final String readLine() throws IOException {
  19.         String line;
  20.         do {
  21.            line = input.readLine();
  22.            if (line == null)
  23.                 return line;
  24.            int comment_pos = line.indexOf("//");
  25.            if (comment_pos >= 0)
  26.                line = line.substring(0, comment_pos);
  27.         } while (line.length() == 0);
  28.         return line;
  29.     }
  30. }
  31.  
  32.