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.mzph.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;如果是&…