Java RandomAccessFile readUTF()方法及示例
RandomAccessFile类readUTF()方法 (RandomAccessFile Class readUTF() method)
readUTF() method is available in java.io package.
readUTF()方法在java.io包中可用。
readUTF() method is used to read this RandomAccessFile as a string.
readUTF()方法用于以字符串形式读取此RandomAccessFile。
readUTF() 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.
readUTF()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
readUTF() method may throw an exception at the time of reading the file as a string.
readUTF()方法在将文件读取为字符串时可能会引发异常。
- 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 all bytes.EOFException :当文件指针在读取所有字节之前到达EOF(文件末尾)时,可能引发此异常。
- UTFDataFormatException: This exception may throw when the bytes denote invalid UTF-8 encoding schemes.UTFDataFormatException :当字节表示无效的UTF-8编码方案时,可能引发此异常。
Syntax:
句法:
public final String readUTF();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of this method is String, it gets Unicode string value.
此方法的返回类型为String ,它获取Unicode字符串值。
Example:
例:
// Java program to demonstrate the example
// of String readUTF() method of
// RandomAccessFile
import java.io.*;
class RAFReadUTF {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!!!");
// Initially set the file pointer
// is at 1 for reading the file
ra_f.seek(0);
// By using readUTF() method is to
// read a data in a string from
// this file
//String str = ra_f.readUTF();
System.out.println("ra_f.readUTF(): " + ra_f.readUTF());
// By using close() method isto
// close this stream ran_f
ra_f.close();
}
}
Output
输出量
ra_f.readUTF(): Welcome in Java World!!!
翻译自: https://www.includehelp.com/java/randomaccessfile-readutf-method-with-example.aspx
Java RandomAccessFile readUTF()方法及示例相关推荐
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- 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对象表示的进程完成其终止为止. 当 ...
- java arraylist.add(),Java ArrayList add()方法与示例
ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...
- java rollback用法,Java Connection rollBack()方法与示例
回滚操作将撤消当前事务所做的所有更改,即,如果调用Connection接口的rollBack()方法,则所有修改都将还原到最后一次提交. 您还可以通过将所需的Savepoint对象作为参数传递给此方法 ...
最新文章
- 中国财团收购飞利浦照明业务遭美封杀
- mysql多列索引不全用,MySQL多列索引的生效规则
- rabbitmq中的队列transient和durable的区别
- python实现图片自动轮番播放
- MIS系统权限控制的一个简便方法
- nexus build docker private registry
- fcntl.h里没有open_国际高中课程里的IB课程 你了解多少?
- 网络工程师HCNA认证学习笔记Day1
- 软件研发过程客观体检指标
- cmake:cmake_minimum_required命令
- org.apache.hadoop.hive.ql.exec.mr.MapRedTask. Could not find status of job:job_1649726530586_123811
- 文献调研-存算一体的实现
- 树模型知识点(1)——决策树
- sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
- C语言输出菱形及其思路
- 剑指offer-字符串总结
- 在字节跳动干了 2 年后端开发,太真实…
- lol服务器维护2021,lol维护几点结束 2021英雄联盟维护最新公告
- 50多个有用的Docker工具集
- Task3:Selenium模块学习及丁香园模拟登录爬取留言板
热门文章
- android新建项目错误,新建Android项目出错
- linux中s权限大小写的区别,Linux中的权限
- unity如何往下挖地形_Unreal Engine地形系统辨析(一)
- matlab bad apple,【bad apple】matlab制作矩阵苹果~
- php源码安装配置,php源码安装时configure配置参数 | 学步园
- android layer阴影,Android Layer-List实现自定义Shape阴影
- 创造型模式——建造者模式
- Oracle GoldenGate简介
- Linux下查看显卡PCIE速率x16x8x4及设定
- linux 查看数据库和表 mysql 命令