代码实例 |
私有方法不可见。
|
public int read() throws IOException
返回字符串中next属性所在的索引处的char值得ASCII码。
代码实例 |
@Test public void testUtil(){ FastStringReader fsr = new FastStringReader("Aaaaa"); try { int n = fsr.read(); System.out.println(n); //n=65 } catch (IOException e) { e.printStackTrace(); } } |
public int read(char cbuf[], int off, int len) throws IOException
将字符串中的内容读到cbuf字符数组中的指定位置,off为起始位置,len为读多少字符,返回读到的实际字符的个数。
代码实例 |
@Test public void testUtil(){ FastStringReader fsr = new FastStringReader("Aaa"); try { char[] c = new char[5]; int n = fsr.read(c, 0, 4); System.out.println(n); //n=3 } catch (IOException e) { e.printStackTrace(); } } |
public long skip(long ns) throws IOException
调过ns个字符读取后面的字符。
代码实例 |
FastStringReader fsr = new FastStringReader("Aaabbb"); try { char[] c = new char[5]; fsr.skip(3); int n = fsr.read(c, 0, 5); System.out.println(n); //n=3 } catch (IOException e) { e.printStackTrace(); } |
public boolean ready() throws IOException
准备好读取FastStringReader。
代码实例 |
FastStringReader fsr = new FastStringReader("Aaabbb"); fsr.ready(); |
public boolean markSupported()
判断FastStringReader是否支持标记位。
代码实例 |
FastStringReader fsr = new FastStringReader("Aaabbb"); boolean b = fsr.markSupported(); System.out.println(b); //b = true |
public void mark(int readAheadLimit) throws IOException
将标记位置为next所指向的下标。
代码实例 |
FastStringReader fsr = new FastStringReader("Aaabbb"); try { fsr.mark(2); } catch (IOException e) { e.printStackTrace(); } |
public void reset() throws IOException
将next下标重置为标记位mark的值。
代码实例 |
FastStringReader fsr = new FastStringReader("Aaabbb"); try { fsr.skip(3); int n = fsr.read(); //n = 98 fsr.reset(); //此时mark = 0 int m = fsr.read(); //m = 65 System.out.println(n + "," + m); } catch (IOException e) { e.printStackTrace(); } |
public void close()
清空FastStringReader中的内容。
代码实例 |
FastStringReader fsr = new FastStringReader("Aaabbb"); fsr.close(); |
所有评论仅代表网友意见