1 19 package org.netbeans.tax.io; 20 21 import java.io.*; 22 23 33 public class RememberingReader extends Reader { 34 35 private final Reader peer; 36 private StringBuffer memory; 37 38 39 public RememberingReader (Reader peer) { 40 this.peer = peer; 41 } 42 43 46 public void startRemembering () { 47 memory = new StringBuffer (); 48 } 49 50 public StringBuffer stopRemembering () { 51 StringBuffer toret = memory; 52 memory = null; 53 return toret; 54 } 55 56 public void close () throws java.io.IOException { 57 peer.close (); 58 } 59 60 public int read (char[] values, int off, int len) throws java.io.IOException { 61 int toret = peer.read (values, off, len); 62 if (memory != null && toret > 0) memory.append (values, off, toret); 63 return toret; 64 } 65 66 } 67 | Popular Tags |