Import java.io.ioException; import java.io.Inputstream;
Public class charterminatedInputStream extends inputstream {
PRIVATE INPUTSTREAM IN;
Private int match [];
Private int buffer [];
Private int POS = 0;
PRIVATE BOOLEAN EndFound = FALSE
public CharTerminatedInputStream (InputStream in, byte [] terminator) {if (terminator == null) {throw new IllegalArgumentException ( "The terminating character array can not be null.");} if (terminator.length == 0) {throw new IllegalArgumentException ("The Terminating Character Array Cannot BE of Zero Length);} match = new int [Terminator.Length]; buffer = new int [Terminator.Length]; for (int i = 0; i Public synchronized void reset () {endfound = false; pOS = 0;} Public int ready () throws oException { IF (endfound) {return -1;} IF (POS == 0) {INT B = IN.READ (); if (b == -1) {endfound = true; return -1;} if (b! = match [0]) {RETURN B;} Buffer [0] = B; POS ;} else {if (buffer [0]! = match [0]) {Return Topchar ();}}} for (int i = 0; i