Java ByteArrayInputStream skip()方法与示例
ByteArrayInputStream类skip()方法 (ByteArrayInputStream Class skip() method)
skip() method is available in java.util package.
skip()方法在java.util包中可用。
skip() method is used to skip the given number of bytes (no_of_bytes) from this stream.
skip()方法用于从此流中跳过给定的字节数(no_of_bytes)。
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 does not throw an exception at the time of skipping bytes.
skip()方法在跳过字节时不会引发异常。
Syntax:
句法:
public void skip();
Parameter(s):
参数:
long no_of_bytes – represents the number of bytes to skip.
long no_of_bytes –表示要跳过的字节数。
Return value:
返回值:
The return type of the method is long, it returns the exact number of bytes to be skipped.
该方法的返回类型为long ,它返回要跳过的确切字节数。
Example:
例:
// Java program to demonstrate the example
// of long skip(long no_of_bytes) method of
// ByteArrayInputStream
import java.io.*;
public class SkipBAIS {public static void main(String[] args) throws Exception {byte[] by = {97,
98,
98,
99,
100
};
// Instantiates ByteArrayInputStream
ByteArrayInputStream byte_s = new ByteArrayInputStream(by);
// By using available() method is to
// return the no. of bytes to be left
// for reading
Integer n_byte = byte_s.available();
System.out.println("Left avail bytes = " + n_byte);
// Read character from the stream
char ch1 = (char) byte_s.read();
char ch2 = (char) byte_s.read();
char ch3 = (char) byte_s.read();
// Display values
System.out.println("ch1: " + ch1);
System.out.println("ch2 : " + ch2);
System.out.println("ch3: " + ch3);
// It skip 1 bytes of data
// from the stream
byte_s.skip(1);
char ch = (char) byte_s.read();
System.out.println("ch: " + ch);
byte_s.close();
}
}
Output
输出量
Left avail bytes = 5
ch1: a
ch2 : b
ch3: b
ch: d
翻译自: https://www.includehelp.com/java/bytearrayinputstream-skip-method-with-example.aspx
Java ByteArrayInputStream skip()方法与示例相关推荐
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- java中skip是什么意思_Java PushbackReader skip()方法与示例
PushbackReader类skip()方法skip()方法在java.io包中可用. skip()方法用于从此PushbackReader流中跳过给定数量的字符,它将阻塞直到存在某些字符输入或发生 ...
- java中skip是什么意思_Java LineNumberInputStream skip()方法与示例
LineNumberInputStream类skip()方法skip()方法在java.io包中可用. skip()方法用于从此LineNumberInputStream流中跳过给定数目的数据字节. ...
- java user directory,Java ProcessBuilder directory()方法与示例
语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...
- Java序列化魔术方法及其示例使用
在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...
- catalog java,Java Connection getCatalog()方法与示例
通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...
- filepermission java,Java FilePermission getActions()方法与示例
FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...
- java方法参数Bundle,Java ResourceBundle keySet()方法及示例
ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...
- java exec waitfor,Java Process waitFor()方法与示例
流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...
最新文章
- python反转字符串(简单方法)及简单的文件操作示例
- 口碑好的mysql数据监控平台_构建狂拽炫酷屌的 MySQL 监控平台
- 类的加载连接和初始化
- php 判断浏览器是ie,js判断是否是ie浏览器
- termux配置python安装kali_安卓安装kali linux之Termux
- memcpy函数实现_等比例缩放c++ opencv 实现
- wince 内存释放_【转载】让我生不如死的WINCE内存泄漏
- idea 自动生成mybaits_Intellij idea中使用Mybatis插件Mybatis Generator
- TeamViewer最新版本TV 13介绍
- android studio 模拟器内存不足,Android Studio模拟器的问题及解决办法
- CAD中怎么创建圆弧?CAD圆弧快捷键应用技巧
- 正在解析主机 失败:未知的名称或服务。 wget: 无法解析主机地址
- centos8之systemd管理服务开机自启动
- ae渲染存在偏移_以后请不要问我AE和PR有什么区别了...
- C++并查集算法(详细)
- php表格所有边框实线,css表格怎么添加边框样式?css表格边框样式总结(附完整实例)...
- 推荐两个免费绘图工具
- 华为荣耀android是什么系统,华为荣耀Magic自主系统梦碎 还是Android操作系统
- PCIe板卡结构尺寸
- mybatis 中if关于数字的判断
热门文章
- android+联系服务器时间,android配置时间服务器+亚洲主要的授时服务器
- bat批处理执行python_.bat批处理添加Python任务
- opencv获取模板旋转角度_OpenCV入门之获取图像的旋转角度
- 神经网络的全连接层_深度神经网络全连接层
- java将date类型转成yyyymmdd_java中的Date怎么转换成YYYYMMDD形式?
- ngOnInit与constructor的区别
- mysql备份:一,Xtrabackup
- linux shell脚本备份mysql数据库
- oracle 10g学习之分组函数
- 读书总结:周鸿祎,我的互联网方法论