randomaccessfile quick start
TRANSCRIPT
![Page 2: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/2.jpg)
2+Agenda
RandomAccessFile overview
Implement CRUD functions by RandomAccessFile Use case diagram Sequence diagram Class diagram classes
![Page 3: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/3.jpg)
3+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
![Page 4: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/4.jpg)
4+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
![Page 5: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/5.jpg)
5+Use Case Diagram
![Page 6: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/6.jpg)
6+Class Diagram
![Page 7: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/7.jpg)
7+DVD.java
Be made up of a couple of setter and getter methods
Defined length for each column
A DVD record
![Page 8: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/8.jpg)
8+
![Page 9: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/9.jpg)
9+DVDClient.java
Play the role of client to do CRUD C (Create): addDVD() R (Read): findAll() and findByCriteria() U (Update): modifyDVD() D (Delete): deleteDVD
![Page 10: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/10.jpg)
10+DvdFileAccess.java
All random access file-related codes are in this class
![Page 11: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/11.jpg)
11+findAll()
![Page 12: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/12.jpg)
+ 12
Retrieve DVD data based on the cursor
![Page 13: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/13.jpg)
+ 13
![Page 14: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/14.jpg)
+ 14
![Page 15: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/15.jpg)
+ 15
findByCriteria()
![Page 16: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/16.jpg)
+ 16
findByCriteria() – cont.
![Page 17: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/17.jpg)
+ 17
persistDvd()
![Page 18: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/18.jpg)
+ 18
![Page 19: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/19.jpg)
+ 19
![Page 20: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/20.jpg)
+ 20
modifyDVD()
![Page 21: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/21.jpg)
+ 21
![Page 22: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/22.jpg)
+ 22
![Page 23: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/23.jpg)
+ 23
deleteDVD()
![Page 24: RandomAccessFile Quick Start](https://reader036.vdocument.in/reader036/viewer/2022062319/555e3595d8b42a63048b48d1/html5/thumbnails/24.jpg)
+ 24