- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomAccessDemo.java
More file actions
Latest commit
22 lines (21 loc) · 722 Bytes
/
Copy pathRandomAccessDemo.java
File metadata and controls
22 lines (21 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
importjava.io.*;
publicclassRandomAccessDemo
{
publicstaticvoidmain(String[] args) throwsException
{
RandomAccessFilerf=newRandomAccessFile("Data.txt","rw");
//byte b[]={'A','B','C','D','E','F','G''H','I','J'};
System.out.print((char)rf.read());
System.out.print((char)rf.read());
System.out.print((char)rf.read());
rf.write('d');
System.out.print((char)rf.read());
rf.skipBytes(3);
System.out.print((char)rf.read());
rf.seek(3);
System.out.print((char)rf.read());
System.out.print(rf.getFilePointer());
rf.seek(rf.getFilePointer()+2);
System.out.print((char)rf.read());
}
}