long skip(long n) void reset CharArrayWriter append(char c) 描述 所述java.io.CharArrayReader.skip(long n)的方法跳过字符。 声明 以下是java.io.CharArrayReader.skip(long n)方法的声明- public long skip(long n) 参数 n - 要跳过的字符数。 返回值 实际跳过的字符数。 异常 IOException - 如果发生任何I / O错误或流已关闭。 实例 以下示例显示了java.io.CharArrayReader.skip(long n)方法的用法。 package com.tutorialspoint; import java.io.CharArrayReader; import java.io.IOException; public class CharArrayReadDemo { public static void main(String[] args) { CharArrayReader car = null; char[] ch = {'A', 'B', 'C', 'D', 'E'}; try { // create new character array reader car = new CharArrayReader(ch); int value = 0; // read till the end of the stream while((value = car.read())!=-1) { // convert integer to char char c = (char)value; // print characters System.out.print(c + "; "); // skip single character long l = car.skip(1); System.out.println("Characters Skipped : "+l); } } catch(IOException e) { // if I/O error occurs e.printStackTrace(); } finally { // releases any system resources associated with the stream if(car!=null) car.close(); } } } 让我们编译并运行上面的程序,这将产生以下结果 A; Characters Skipped : 1 C; Characters Skipped : 1 E; Characters Skipped : 0 void reset CharArrayWriter append(char c)