1 19 20 package org.netbeans.modules.java.source.engine; 21 22 import java.io.CharArrayReader ; 23 import java.io.IOException ; 24 25 28 public class SourceReader extends CharArrayReader { 29 30 35 public SourceReader(char[] src) { 36 super(src); 37 } 38 39 42 public long seek(int offset) throws IOException { 43 return skip(offset - pos); 44 } 45 46 55 public char[] getCharsTo(int offset) throws IOException { 56 int len = offset - pos; 57 if (len < 0 || offset > super.count) 58 throw new IOException ("invalid offset: " + offset); 59 char[] buf = new char[len]; 60 read(buf); 61 return buf; 62 } 63 64 69 public int getPos() { 70 return pos; 71 } 72 } 73 74 | Popular Tags |