Java RandomAccessFile skipBytes()方法與示例

RandomAccessFile類skipBytes()方法 (RandomAccessFile Class skipBytes() method)

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

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

  • skipBytes() method is used to skip the given number of bytes in this file and possibly set the given parameter to the least value 0.

    skipBytes()方法用于跳過此文件中給定的字節數,并可能將給定的參數設置為最小值0。

  • skipBytes() 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.

    skipBytes()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • skipBytes() method may throw an exception at the time of skipping bytes.

    skipBytes()方法在跳過字節時可能會引發異常。

    IOException: This exception may throw an exception while performing input/output operation.

    IOException :在執行輸入/輸出操作時,此異常可能會引發異常。

Syntax:

句法:

    public void skipBytes(int no_of_byte);

Parameter(s):

參數:

  • int no_of_byte – represents the number of bytes to skip.

    int no_of_byte –表示要跳過的字節數。

Return value:

返回值:

The return type of this method is int, it returns the skipped bytes.

此方法的返回類型為int ,它返回跳過的字節。

Example:

例:

// Java program to demonstrate the example 
// of void skipBytes(int no_of_byte) method of
// RandomAccessFile
import java.io.*;
class RAFSkipBytes {
public static void main(String[] args) throws Exception {
// Instantiate a random access file
// object with file name and permissions
RandomAccessFile ra_f = new RandomAccessFile("e:/includehelp.txt", "rw");
// By using writeUTF() method is to 
// write data to the file
ra_f.writeUTF("Welcome in Java World!!!");
// by using seek() method is to 
// set the current file indicator
// from where read/write could 
// start i.e. we set here 0 so reading
// will be done from 0 till EOF
ra_f.seek(0);
// By using readUTF() method is to 
// read a data in a string from
// this file
System.out.println("ra_f.readUTF(): " + ra_f.readUTF());
// By using skipBytes() method isto
// return the given number of bytes to
// be skipped 
int bytes = ra_f.skipBytes(2);
System.out.println("ra_f.skipBytes(2): " + bytes);
// By using close() method isto
// close this stream ran_f
ra_f.close();
}
}

Output

輸出量

ra_f.readUTF(): Welcome in Java World!!!
ra_f.skipBytes(2): 2

翻譯自: https://www.includehelp.com/java/randomaccessfile-skipbytes-method-with-example.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542050.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542050.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542050.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

rhcs集群套件—紅帽6的高可用

含義及理解: RHCS是Red Hat Cluster Suite的縮寫,也就是紅帽子集群套件,RHCS是一個能夠提供高可用性、高可靠性、負載均衡、存儲共享且經濟廉價的集群工具集合,,它將集群系統中三大集群架構(高可用性集群、…

MapReduce二次排序

2019獨角獸企業重金招聘Python工程師標準>>> 默認情況下,Map輸出的結果會對Key進行默認的排序,但是有時候需要對Key排序的同時還需要對Value進行排序,這時候就要用到二次排序了。下面我們來說說二次排序 1、二次排序原理 我們把二…

數據有序_詳解數據庫插入性能優化:合并+事務+有序數據進行INSERT操作

概述對于一些數據量較大的系統,數據庫面臨的問題除了查詢效率低下,還有就是數據入庫時間長。特別像報表系統,每天花費在數據導入上的時間可能會長達幾個小時或十幾個小時之久。因此,優化數據庫插入性能是很有意義的。其實最有效的…

Java ProcessBuilder environment()方法與示例

ProcessBuilder類的environment()方法 (ProcessBuilder Class environment() method) environment() method is available in java.lang package. environment()方法在java.lang包中可用。 environment() method is used to return Map interfaces of this process builder env…

容器內應用日志收集方案

容器化應用日志收集挑戰 應用日志的收集、分析和監控是日常運維工作重要的部分,妥善地處理應用日志收集往往是應用容器化重要的一個課題。 Docker處理日志的方法是通過docker engine捕捉每一個容器進程的STDOUT和STDERR,通過為contrainer制定不同log dri…

python統計行號_利用Python進行數據分析(第三篇上)

上一篇文章我記錄了自己在入門 Python 學習的一些基礎內容以及實際操作代碼時所碰到的一些問題。這篇我將會記錄我在學習和運用 Python 進行數據分析的過程:介紹 Numpy 和 Pandas 兩個包運用 Numpy 和 Pandas 分析一維、二維數據數據分析的基本過程實戰項目【用 Pyt…

lnmp架構搭建—源碼編譯(nginx、mysql、php)

含義及理解: LNMP LinuxNginxMysqlPHP:LNMP是指一組通常一起使用來運行動態網站或者服務器的自由軟件名稱首字母縮寫。L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可以指P…

Java PipedInputStream available()方法與示例

PipedInputStream類的available()方法 (PipedInputStream Class available() method) available() method is available in java.io package. available()方法在java.io包中可用。 available() method is used to return the number of available bytes left that can be read …

解析xml_Mybatis中mapper的xml解析詳解

上一篇文章分析了mapper注解關鍵類MapperAnnotationBuilder,今天來看mapper的項目了解析關鍵類XMLMapperBuilder。基礎介紹回顧下之前是在分析configuration的初始化過程,已經進行到了最后一步mapperElement(root.evalNode("mappers"))&#x…

lnmp—MemCache的作用

含義及理解: 1 . memcache是一個高性能的分布式的內存對象緩存系統,用于動態web應用以減輕數據庫負擔。通過在內存里維護一個統一的巨大的hash表,來存儲經常被讀寫的一些數組與文件,從而極大的提高網站的運行效率。 memcache是一…

Java ListResourceBundle getKeys()方法與示例

ListResourceBundle類的getContents()方法 (ListResourceBundle Class getContents() method) getContents() method is available in java.util package. getContents()方法在java.util包中可用。 getContents() method is used to return an enumeration of all the keys tha…

orale用戶密碼過期處理

使用具有管理權限的用戶登錄1、查看用戶的proifle是哪個,一般是default:SELECT username,PROFILE FROM dba_users;2、查看指定概要文件(如default)的密碼有效期設置:sql>SELECT * FROM dba_profiles s WHERE s.prof…

python字典怎么設置_在python中設置字典中的屬性

在python中設置字典中的屬性是否可以在python中從字典創建一個對象,使每個鍵都是該對象的屬性?像這樣的東西:d { name: Oscar, lastName: Reyes, age:32 }e Employee(d)print e.name # Oscarprint e.age 10 # 42我認為這幾乎與這個問題相反…

Java ObjectInputStream readByte()方法與示例

ObjectInputStream類readByte()方法 (ObjectInputStream Class readByte() method) readByte() method is available in java.io package. readByte()方法在java.io包中可用。 readByte() method is used to read a byte (i.e. 8 bit) of data from this ObjectInputStream. re…

openresty—實現緩存前移

含義及理解: OpenResty(又稱:ngx_openresty) 是一個基于 NGINX 的可伸縮的 Web 平臺,由中國人章亦春發起,提供了很多高質量的第三方模塊。 其目標是讓Web服務直接跑在Nginx服務內部,充分利用Nginx的非阻塞I/O模型&am…

Nginx+Keepalived+Tomcat之動靜分離的web集群

NginxKeepalivedTomcat之動靜分離的web集群 博客分類: webserverNginxKeepalivedTomcat之動靜分離的web集群為小公司提供大概一天持續在100萬/日之間訪問的高性能、高可用、高并發訪問及動靜分離的web集群方案NginxKeepalived 高可用、反向代理NginxPHP …

安裝完成后的配置_cent os7 默認安裝后的一般配置

在安裝cent os7后,進入系統會出現一些命令無法執行。這是因為最小化沒有安裝包含的軟件包。這時候先要配置一下基本的IP參數,(包括動態,靜態,或者是雙網卡綁定)。我們在虛擬機中模擬操作一下,配置文件在/etc/sysconfig…

Java Integer類lowerOneBit()方法與示例

整數類lowerOneBit()方法 (Integer class lowestOneBit() method) lowestOneBit() method is available in java.lang package. minimumOneBit()方法在java.lang包中可用。 lowestOneBit() method is used to find at most only single 1’s bit from the rightmost side one b…

lnmp構架——對tomcat詳解

tomcat的安裝部署 安裝jdk和tomcat tar zxf jdk-7u79-linux-x64.tar.gz -C /usr/local/ tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local/做好軟連接便于訪問 cd /usr/local ln -s jdk1.7.0_79/ java ln -s apache-tomcat-7.0.37/ tomcat配置環境變量 vim /etc/profile…

Linux 查找文件

find 查找目錄 -name "文件名"find / -name "php.ini"locate 文件名locate php.ini 一:locate命令 locate命令用于查找文件,它比find命令的搜索速度快,它需要一個數據庫,這個數據庫由每天的例行工作&#xff…