stringreader

StringReader类skip()方法 (StringReader Class skip() method)

  • skip() method is available in java.io package.

    skip()方法在java.io包中可用。

  • skip() method is used to skip the given number of characters in the stream.

    skip()方法用于跳过流中给定数量的字符。

  • skip() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    skip()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • skip() method may throw an exception at the time of skipping the number of characters.

    skip()方法在跳过字符数时可能会引发异常。

    IOException: This exception may throw when getting any input/output error while performing.

    IOException :在执行过程中遇到任何输入/输出错误时,可能引发此异常。

Syntax:

句法:

    public long skip(long number);

Parameter(s):

参数:

  • long number – represents the number of characters to skip.

    长数字 -表示要跳过的字符数。

Return value:

返回值:

The return type of the method is long, it returns the exact number of characters skipped.

该方法的返回类型为long ,它返回跳过的确切字符数。

Example:

例:

// Java program to demonstrate the example
// of long skip(long number) method of StringReader
import java.io.*;
public class SkipOfSR {public static void main(String[] args) throws Exception {StringReader str_r = null;
try {// Instantiates StringReader
str_r = new StringReader("Java World");
// Loop to read until available
// bytes left
for (int val = 0; val <= 4; ++val) {// Read corresponding char value
char ch = (char) str_r.read();
// Display value of ch
System.out.println("ch: " + ch + " ");
// By using skip() method is
// to skip 1 bytes of data
// from str_r
long skip = str_r.skip(1);
System.out.println("str_r.skip(1): " + skip);
}
} catch (Exception ex) {System.out.println(ex.toString());
} finally {// with the help of this block is to
// free all necessary resources linked
// with the stream
if (str_r != null) {str_r.close();
}
}
}
}

Output

输出量

ch: J
str_r.skip(1): 1
ch: v
str_r.skip(1): 1
ch:
str_r.skip(1): 1
ch: o
str_r.skip(1): 1
ch: l
str_r.skip(1): 1

翻译自: https://www.includehelp.com/java/stringreader-skip-method-with-example.aspx

stringreader

stringreader_Java StringReader skip()方法与示例相关推荐

  1. java中skip是什么意思_Java PushbackReader skip()方法与示例

    PushbackReader类skip()方法skip()方法在java.io包中可用. skip()方法用于从此PushbackReader流中跳过给定数量的字符,它将阻塞直到存在某些字符输入或发生 ...

  2. java中skip是什么意思_Java LineNumberInputStream skip()方法与示例

    LineNumberInputStream类skip()方法skip()方法在java.io包中可用. skip()方法用于从此LineNumberInputStream流中跳过给定数目的数据字节. ...

  3. Java BufferedReader skip()方法与示例

    BufferedReader类skip()方法 (BufferedReader Class skip() method) skip() method is available in java.io p ...

  4. java scanner_Java Scanner skip()方法与示例

    java scanner 扫描仪类skip()方法 (Scanner Class skip() method) Syntax: 句法: public Scanner skip(Pattern patt ...

  5. Java FilterInputStream skip()方法与示例

    FilterInputStream类skip()方法 (FilterInputStream Class skip() method) skip() method is available in jav ...

  6. Java PushbackInputStream skip()方法与示例

    PushbackInputStream类skip()方法 (PushbackInputStream Class skip() method) skip() method is available in ...

  7. Java ByteArrayInputStream skip()方法与示例

    ByteArrayInputStream类skip()方法 (ByteArrayInputStream Class skip() method) skip() method is available ...

  8. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  9. python os path isfile_Python path.isfile方法代码示例

    本文整理汇总了Python中os.path.isfile方法的典型用法代码示例.如果您正苦于以下问题:Python path.isfile方法的具体用法?Python path.isfile怎么用?P ...

最新文章

  1. Android 8.0新特性(看这篇文章就够了)
  2. JS 借助 pako.js 实现网络请求获取 gzip 数据流并解析, 解决汉字乱码
  3. 使用您自己的规则在Eclipse中自定义PMD
  4. (企业案例)Nacos Config 进阶使用
  5. 淡定!不要因为纳入了高考和二级考试甚至极个别小学课程就盲目夸大Python!...
  6. 解决Linux下使用sqlplus不能使用上下键,退格键
  7. sourceinsight4.0安装破解( 内含sublime text配色方案)
  8. 分段锁——ConcurrentHashMap
  9. 游竹林寺不得,谈封山收费
  10. THAAD反导必将部署,各方已接受事实
  11. Android Studio打开项目提示找不到sdk路径的问题。
  12. 字体引起的用户密码错误
  13. Escape HDU - 3533
  14. WIN10 本地打印机没有“打印机属性”
  15. 设计模式—策略模式(Strategy Pattern)
  16. unidbg第二讲 例子讲解com.sun.jna.JniDispatch32
  17. 【VRP问题】基于遗传算法求解带容量的VRP问题matlab源码
  18. 辅助小工具---FooView
  19. 掌握模拟电路设计需要阅读的几本参考书!
  20. docker-error-at \\\“/dev/mqueue\\\“ caused \\\“no such device

热门文章

  1. 电容降压LED驱动电路
  2. linux python3_在Linux上安装Python 3
  3. C++面试常见问题一
  4. python123平台作业答案第十一周_马哥2016全新Linux+Python高端运维班第十次作业
  5. html中所有的标签,HTML中的所有标签及其做用!
  6. Linux 出现Permission denied的解决办法
  7. 防火墙firewalld
  8. Oracle GoldenGate微服务架构
  9. docker-compose 运行 Flask 应用最佳实践
  10. WAS集群系列(5):集群搭建:步骤3:安装IHS软件