1 17 18 package org.objectweb.jac.util; 19 20 import java.io.Reader ; 21 import java.io.IOException ; 22 23 24 29 30 public class PushbackReader extends java.io.PushbackReader 31 { 32 33 int position; 34 35 public PushbackReader(Reader in) { 36 super(in); 37 } 38 39 44 public PushbackReader(Reader in, int size) { 45 super(in,size); 46 } 47 48 public int read() throws IOException { 49 int c = super.read(); 50 position++; 51 return c; 52 } 53 54 public int read(char cbuf[], int off, int len) throws IOException 55 { 56 int nbRead = super.read(cbuf,off,len); 57 if (nbRead!=-1) { 58 position += nbRead; 59 } 60 return nbRead; 61 } 62 63 public void unread(int c) throws IOException { 64 super.unread(c); 65 position--; 66 } 67 68 public void unread(char cbuf[], int off, int len) throws IOException { 69 super.unread(cbuf,off,len); 70 position -= len; 71 } 72 73 76 public int getPosition() { 77 return position; 78 } 79 } 80 | Popular Tags |