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