RandomAccessFile简介 : 随机存取文件 « 文件 « Java 教程

En
Java 教程
1. 语言基础
2. 数据类型
3. 操作符
4. 流程控制
5. 类定义
6. 开发相关
7. 反射
8. 正则表达式
9. 集合
10. 线
11. 文件
12. 泛型
13. 本土化
14. Swing
15. Swing事件
16. 二维图形
17. SWT
18. SWT 二维图形
19. 网络
20. 数据库
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web服务SOA
27. EJB3
28. Spring
29. PDF
30. 电子邮件
31. 基于J2ME
32. J2EE应用
33. XML
34. 设计模式
35. 日志
36. 安全
37. Apache工具
38. 蚂蚁编译
39. JUnit单元测试
Java
Java 教程 » 文件 » 随机存取文件 
11. 38. 1. RandomAccessFile简介
  1. A RandomAccessFile employs an internal pointer that points to the next byte to read.
  2. This pointer is zero-based and the first byte is indicated by index 0.
  3. When first created, a RandomAccessFile points to the first byte.
  4. You can change the pointer's position by invoking the seek method.
  5. The skipBytes method moves the pointer by the specified number of bytes.
  6. If skipping offset number of bytes would pass the end of file, the internal pointer will only move to as much as the end of file.
  7. The skipBytes method returns the actual number of bytes skipped.

When opening a file using a RandomAccessFile, you can choose whether to open it read-only or read write.

public RandomAccessFile (File file, String modethrows FileNotFoundException
public RandomAccessFile (String filePath, String modethrows FileNotFoundException

The value of mode can be one of these:

"r".     Open for reading only.

      "rw".    Open for reading and writing. 
               If the file does not already exist, RandomAccessFile creates the file.

      "rws".   Open for reading and writing and require that every update to the file's content and metadata be written synchronously.

      "rwd".   Open for reading and writing and require that every update to the file's content (but not metadatabe written synchronously.
11. 38. 随机存取文件
11. 38. 1. RandomAccessFile简介
11. 38. 2. Employs RandomAccessFile to store ints and changes the value of the third int.
11. 38. 3. 寻求文件指针RandomAccessFile
11. 38. 4. 从RandomAccessFile使用FileChannel
11. 38. 5. 以RandomAccessFile使用FileChannel写整型
11. 38. 6. 使用RandomAccessFile保存和读取
11. 38. 7. 使用RandomAccessFile扭转文件
11. 38. 8. Test file pointer manipulation between FileChannel and RandomAccessFile objects.
11. 38. 9. 在现有的文件附加数据
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.