RandomAccessFile类readInt()方法 (RandomAccessFile Class readInt() method)

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

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

  • readInt() method is used to read signed 32-bit integer value from this RandomAccessFile.

    readInt()方法用于从此RandomAccessFile读取带符号的32位整数值。

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

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

  • readInt() method may throw an exception at the time of reading integer.

    readInt()方法在读取整数时可能会引发异常。

    • IOException: This exception may throw an exception while performing input/output operation.IOException :在执行输入/输出操作时,此异常可能会引发异常。
    • EOFException: This exception may throw when the file pointer reaches EOF (End-Of-File) before reading 4 bytes.EOFException :当文件指针在读取4个字节之前到达EOF(文件末尾)时,可能引发此异常。

Syntax:

句法:

    public final int readInt();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is int, it returns the 4 bytes of data from this RandomAccessFile manipulated as an int value.

此方法的返回类型为int ,它从作为Random值操纵的RandomAccessFile中返回4个字节的数据。

Example:

例:

// Java program to demonstrate the example
// of int readInt() method of
// RandomAccessFile
import java.io.*;
class RAFReadInt {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 writeFloat() method is to
// write float to the file
ra_f.writeInt(500);
// Initially set the file pointer
// is at 1 for reading the file
ra_f.seek(1);
// By using readInt() method is to
// read int upto signed 4 bytes
// from the file
int i = ra_f.readInt();
System.out.println("ra_f.readInt(): " + i);
// By using close() method isto
// close this stream ran_f
ra_f.close();
}
}

Output

输出量

ra_f.readInt(): 128210

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

Java RandomAccessFile readInt()方法与示例相关推荐

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

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

  2. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  3. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  4. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  5. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  6. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  7. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  8. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

  9. java rollback用法,Java Connection rollBack()方法与示例

    回滚操作将撤消当前事务所做的所有更改,即,如果调用Connection接口的rollBack()方法,则所有修改都将还原到最后一次提交. 您还可以通过将所需的Savepoint对象作为参数传递给此方法 ...

最新文章

  1. Binder 驱动详解(下)
  2. Equals方法与==运算符的使用
  3. MATLAB的GUI中给坐标轴四周加上边框
  4. python 从大到小循环_python算法(3) 插入排序
  5. 蓝桥杯2020答案c语言b组,2020十月份蓝桥杯B组省赛题解大全(害!附题面文件和部分代码~)...
  6. mac下使用mysql
  7. 我的树莓派3配置脚本
  8. Ubuntu下bin文件的安装
  9. 淘宝账号如何快速提升到更高等级
  10. 博客备份系统之一:PDF,Word,TXT文件操作类
  11. 海康威视API-单帧数据捕获并保存成JPEG图片NET_DVR_CaptureJPEGPicture
  12. 论文笔记:Visual Domain Adaptation with Manifold Embedded Distribution Alignment
  13. fidder配合夜神模拟器进行抓包
  14. Kubernetes kube-proxy 如何与 iptables 完美配合使用
  15. IP-guard和Ping32屏幕监控对比
  16. Spring7种事务的传播行为
  17. 什么是FIR filter?
  18. 齐鲁工业大学计算机考研资料汇总
  19. 无法安装 64 位版本的 Office
  20. 计算机毕业设计SSM大数据与智能工程系教师档案管理系统【附源码数据库】

热门文章

  1. WebCrack:网站后台弱口令批量检测工具
  2. 移动端UC /QQ 浏览器的部分私有Meta 属性
  3. 在HTML5中如何利用Canvas处理并存储图片
  4. N76E003---看门狗
  5. burpsuite破解版
  6. Gradle中的buildScript,gradle wrapper,dependencies等一些基础知识
  7. 运维人员日常工作(转自老男孩)
  8. [导入]一再的变故,终于决定何去何从.
  9. 字符大小端aix linux,long, unsigned long不是跨平台的(慎用)
  10. java scala 获取类_在Scala 2.10中获取java.lang.Class [T]的Scala类型