黑马程序员技术交流社区
标题:
随机流的学习
[打印本页]
作者:
木子小四
时间:
2016-4-11 14:17
标题:
随机流的学习
学习代码:
--------------------------------------------
package com.heima.test;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
public class Test4 {
/**
* 随机访问流,(RandomAccessFile类),不属于流.是object的子类.但融合了inoutstream 和 outputstream的功能;
*
* 有read(),write(),seek()方法
* @throws Exception
*/
public static void main(String[] args) throws Exception {
RandomAccessFile raf = new RandomAccessFile("raf.txt","rw");
//raf.write(98);
int x = raf.read();
System.out.println(x);
//指定位置设置指针
raf.seek(8);
raf.write(99);
raf.close();
}
}
复制代码
作者:
kcufow
时间:
2016-4-11 17:46
学习学习
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2