RandomAccessFile Quick Start

2,002 views 24 slides Jul 25, 2009
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

No description available for this slideshow.


Slide Content

RandomAccessFile Quick Start Albert Guo [email protected] 1

Agenda RandomAccessFile overview Implement CRUD functions by RandomAccessFile U se case diagram S equence diagram C lass diagram classes 2

What is RandomAccessFile ? A random access file behaves like a large array of bytes stored in the file system. There is a kind of cursor, or index into the implied array, called the file pointer; input operations read bytes starting at the file pointer and advance the file pointer past the bytes read. Random-access files are solution Instant access Insert record without destroying other data Update/delete items without changing other data 3

What is RandomAccessFile ? imposes no structure on files Programmer must create random-access files Simplest way: fixed-length records Calculate position in file from record size and key 4

Use Case Diagram 5

Class Diagram 6

DVD.java B e made up of a couple of setter and getter methods D efined length for each column 7 A DVD record

8

DVDClient.java Play the role of client to do CRUD C (Create): addDVD () R (Read): findAll () and findByCriteria () U (Update): modifyDVD () D (Delete): deleteDVD 9

DvdFileAccess.java A ll random access file-related codes are in this class 10

findAll () 11

12 R etrieve DVD data based on the cursor

13

14

findByCriteria () 15

findByCriteria ( ) – cont. 16

persistDvd () 17

18

19

modifyDVD () 20

21

22

deleteDVD () 23

24