博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RandomeAccessFile - read write
阅读量:4306 次
发布时间:2019-06-06

本文共 892 字,大约阅读时间需要 2 分钟。

RandomeAccessFile

use write replace writeBytes

public class RandomAccessFileTest {    public static void main(String[] args) {        try {            RandomAccessFile file= new RandomAccessFile("c://temp//in.txt","rw");            System.out.println(file.readLine());                        file.seek(file.length());            //clear all//            file.setLength(0l);                        //use write() to replace writeBytes            file.write("hello ross test".getBytes());            //writeBytes will has issue on UTF8//            file.writeBytes("");            file.close();        } catch (FileNotFoundException e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (IOException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }    }}

 

转载于:https://www.cnblogs.com/kakaisgood/p/9542287.html

你可能感兴趣的文章
tomcat调优方案Maximum number of threads (200) created for connector with address null and port 8091...
查看>>
java类的加载机制
查看>>
MDK linker和debug的设置以及在RAM中调试
查看>>
CocosCreator2.1.0渲染流程与shader
查看>>
制作新网络框架快速自动生成消息结构体的编辑器
查看>>
[转]Device Context 设备环境 设备上下文 理解
查看>>
事务的传播性和隔离级别
查看>>
2018.3.24 struct
查看>>
Linux系统删掉多个文件
查看>>
【随笔】Win7下GVIM的安装与配置
查看>>
协程,IO模式
查看>>
移动端meta标签
查看>>
是前端类库还是前端框架?
查看>>
解决glib2.0缺失问题 分类: LINUX 20...
查看>>
一些杂想
查看>>
js原型和原型链
查看>>
工作区和暂存区
查看>>
cf B. Fixed Points
查看>>
4步win7下简单FTP服务器搭建(试验成功)
查看>>
C#特性-表达式树
查看>>