Java RandomAccessFile getFilePointer()方法與示例

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

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

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

  • getFilePointer() method is used to get the current pointer in the RandomAccessFile stream.

    getFilePointer()方法用于獲取RandomAccessFile流中的當前指針。

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

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

  • getFilePointer() method does not throw an exception at the time of returning file pointer.

    返回文件指針時, getFilePointer()方法不會引發異常。

Syntax:

句法:

    public long getFilePointer();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of this method is long, it returns the pointer from the starting of the file at which the next read or write happens.

此方法的返回類型為long ,它從發生下一次讀取或寫入的文件的開頭返回指針。

Example:

例:

// Java program to demonstrate the example 
// of long getFilePointer() method of
// RandomAccessFile
import java.io.*;
class RAFGetFilePointer {
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 in the file
ra_f.writeUTF("Welcome, in Java World!!!");
// Initially set the file pointer
// is at 0 for reading the file
ra_f.seek(0);
// To read file content by using
// readUTF()
System.out.println("ra_f .readUTF(): " + ra_f.readUTF());
// By using getFilePointer() method is to
// return the file pointer in bytes at which
// the next read/write occurs
System.out.println("ra_f.getFilePointer(): " + ra_f.getFilePointer());
// By using close() method isto
// close this stream ran_f
ra_f.close();
}
}

Output

輸出量

ra_f .readUTF(): Welcome, in Java World!!!
ra_f.getFilePointer(): 27

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

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

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

相關文章

先進技術android,React Native實戰(JavaScript開發iOS和Android應用)/計算機科學先進技術譯叢...

導語內容提要本書作者Nader Dabit是AWS Mobile開發人員、React Native Training創始人和React Native Radio播客主持人。本書旨在幫助iOS、Android和Web開發人員學習使用React Native框架,構建高質量的iOS和Android應用程序。書中介紹了React Native入門基礎知識&am…

開發類似vs的黑色風格_傳聞:2020年《使命召喚》將是《黑色行動》重啟作品

據可信度較高的消息源透露,2020 年的《使命召喚》將是《黑色行動》的重啟作。而據之前的報道,《黑色行動》開發商 Treyarch 正在開發今年的《使命召喚》, Sledgehammer Games 和 Raven Software 負責輔助工作。該項目代號為“宙斯”&#xff…

ubuntu中 不同JDK版本之間的切換

Ubuntu中JDK 的切換前提是同時安裝了多個版本,如jdk7和jdk8,若要切換,在終端輸入: sudo update-alternatives --config javasudo update-alternatives --config javac

osi模型:七層模型介紹_聯網| OSI模型能力問題和解答 套裝1

osi模型:七層模型介紹1) There are the following statements that are given below, which of them are correct about the OSI model? The OSI model is a reference model that describes the network functionalities.The OSI model is an implemented model that describ…

華為鴻蒙系統正式登場,華為自研鴻蒙系統將于8月9日正式登場,還有全新的鴻鵠芯片...

最近華為發布了很多手機:榮耀20系列手機、榮耀9X系列、華為Nova 5系列,以及7月26日發布的華為Nova5i Pro和華為首部5G手機Mate20 X 5G版,這些手機將成為華為下半年的出貨主力,市場份額能否超過50%就看這些手機的表現了。華為還將在…

pythonencode和decode_Python3的decode()與encode()

python3的decode()與encode()Tags: Python Python3對于從python2.7過來的人,對python3的感受就是python3對文本以及二進制數據做了比較清晰的區分。文本總是Unicode,由str類型進行表示,二進制數據使用bytes進行表示,不會將str與bytes偷偷的混…

微信小程序 開發 微信開發者工具 快捷鍵

微信小程序已經跑起來了.快捷鍵設置找了好久沒找到,完全憑感覺.圖貼出來.大家看看. 我現在用的是0.10.101100的版本,后續版本更新快捷鍵也應該不會有什么變化. 現在貌似不能修改.如果有同學找到修改的方法,麻煩告訴我.謝謝. 微信小程序代碼編輯快捷鍵 常用快捷鍵 格式調整 Ctrl…

java 根據類名示例化類_Java MathContext類| 帶示例的getRoundingMode()方法

java 根據類名示例化類MathContext類的getRoundingMode()方法 (MathContext Class getRoundingMode() method) getRoundingMode() method is available in java.math package. getRoundingMode()方法在java.math包中可用。 getRoundingMode() method is used to get the Roundi…

python中xy坐標如何從十個中找到最遠的兩個_python – Opencv單應性從像素xy坐標中查找全局xy坐標...

我試圖找到變換矩陣H,以便我可以乘以(x,y)像素坐標并得到(x,y)真實世界坐標.這是我的代碼:import cv2import numpy as npfrom numpy.linalg import invif __name__ __main__ :D[159.1,34.2]I[497.3,37.5]G[639.3,479.7]A[0,478.2]# Read source image.im_src cv2.…

[Android] Android統計Apk , jar包方法數

reference to : http://www.jianshu.com/p/61e8f803e0d1 Android在開發過程中,隨著引用的庫以及業務的增多,不可避免的會出現64K limit問題,也就是方法數過多的問題,Java代碼中的Method總數和Field總數都不能超過65535個&#xff…

type c pin定義_在C中定義宏以設置和清除PIN的位

type c pin定義Given a PIN (value in HEX) and bit number, we have to SET and then CLEAR given bit of the PIN (val) by using Macros. 給定一個PIN(十六進制值)和位數,我們必須使用宏將SET(設置),然后清除給定的PIN(值)位(值)。 Macros definitio…

android9有深色模式嗎,深色模式還是黑色模式?微信把所有人都搞懵了

原標題:深色模式還是黑色模式?微信把所有人都搞懵了前一陣子,微信正式加入了對“深色模式”的支持,這也是除了Windows Phone 版本以外微信第一次從系統層面支持深色模式。雖然這次更新離WWDC上的演示已經過去了9個月,但…

網站后端_Python+Flask.0007.FLASK構造跳轉之301跳轉與302重定向?

構造地址:說明: FLASK支持通過視圖函數及傳參來構造URL,而且未來修改URL可一次性修改,且默認構建會轉義特殊字符和Unicode數據,這些工作不需要我們自己處理,且不僅支持在上下文中構造而且還支持在模版文件中構造#!/usr/bin/env python # -*- coding: utf-8 -*- ""&qu…

python插值程序_計算方法(2)——插值法(附Python程序)

給定一些數據,生成函數的方式有兩種:插值,回歸。插值而得到的函數通過數據點,回歸得到的函數不一定通過數據點。下面給出拉格朗日插值,牛頓插值和Hermite插值的程序,具體原理可參考課本,不再贅述…

java中cbrt_Java Math類靜態double cbrt(double d)示例

java中cbrt數學類靜態double cbrt(double d) (Math Class static double cbrt(double d)) This method is available in java.lang package. 此方法在java.lang包中可用。 This method is used to find the cube root of the given parameter in the method. 此方法用于查找方法…

html中電子郵件怎么寫,談html mailto(電子郵件)實際應用

大家知道,mailto是網頁設計制作中的一個非常實用的html標簽,許多擁有個人網頁的朋友都喜歡在網站的醒目位置處寫上自己的電子郵件地址,這樣網頁瀏覽者一旦用鼠標單擊一下由mailto組成的超級連接后,就能自動打開當前計算機系統中默…

python爬蟲urllib 數據處理_Python 爬蟲筆記之Urllib的用法

urllib總共有四個子模塊,分別為request,error,parse,robotparserrequest用于發送request(請求)和取得response(回應)error包含request的異常,通常用于捕獲異常parse用于解析和處理urlrobotparser用于robot.txt文件的處理urllib.request 模塊import urllib.requestresponseurlli…

語法分析-C語言程序

⑴<C語言程序>——〉begin<語句串>end ⑵<語句串>——〉<語句>{&#xff1b;<語句>} ⑶<語句>——〉<賦值語句> ⑷<賦值語句>——〉ID&#xff1a;<表達式> ⑸<表達式>——〉<項>{<項> | -<項>…

python中對比數組長度_在Python中檢索數組長度的首選方法

python中對比數組長度The __len__() is a method on container types. However, python also provides another option of retrieving the length of an array, using the method len(). __len __()是關于容器類型的方法。 但是&#xff0c;python還使用len()方法提供了另一個檢…

html window 屬性,html中window對象top 、self 、parent 等屬性

top 屬性返回最頂層的先輩窗口。該屬性返回對一個頂級窗口的只讀引用。如果窗口本身就是一個頂級窗口&#xff0c;top 屬性存放對窗口自身的引用。如果窗口是一個框架&#xff0c;那么 top 屬性引用包含框架的頂層窗口。下面的例子窗口是否在一個框架中&#xff0c;如果是&…