How to Make Virtual Disk - OOP Final Project

1,813 views
1,732 views

Published on

Guide to make virtual disk for my class' final project.

Virtual disk has the same capabilities as the "standard" disk which is able to:
- add file
- remove file
- list the content

I hope this guide will be useful for you completing this final project :)

Published in: Self Improvement, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,813
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

How to Make Virtual Disk - OOP Final Project

  1. 1. WARNING! For you who like to think ways on your own, I suggest you not to read this guide as I will spoiler lots of stuff here :p<br />Object Oriented Programming Final Project – Virtual Disk<br />Ok, in short this is a guide for you to make the OOP Final Project: Virtual Disk. I have researched about this project and find it not really hard as long as you know what you have to do. In this guide, I’ll tell you what I’ve known about it. But still you have to think about the implementation by yourself. Hope this guide will help you <br />How will the Virtual Disk work?<br />There are three main features that your virtual disk may have: add, remove, and list.<br />To add file, these are the steps:<br />To remove file, these are the steps:<br />And to list the files, simply use your File Allocation Table.<br />How to Zip and Unzip it?<br />You can use the java.util.zip.* to zip and unzip file. Refer to this link to learn how to zip and unzip it: http://java.sun.com/developer/technicalArticles/Programming/compression/ <br />How to convert files into array of bytes and vice versa?<br />Use the class FileInputStream to convert files into array of bytes, and class FileOutputStream to convert array of bytes into files. Use the method: read(b[], offset, length) from FileInputStream and write(b[], offset, length).<br />Refer to this link to learn how to use it: http://www.mkyong.com/java/how-to-convert-array-of-bytes-into-file/ (I haven’t tried the code myself).<br />How to allocate the bytes into the Virtual Disk?<br />Since you need to jump from each sector randomly without erasing the previous data, you need to use RandomAccessFile class as your virtual disk. Make use of these methods: seek(), write(), and read() to jump from one sector to the other, add, and remove file from the virtual disk.<br />Refer to Java Documentation to learn how to implement these methods.<br />Add file<br />Remove file<br />What is the FAT (File Allocation Table)?<br />FAT keeps track of your files: where all the parts are stored. Interpreting what Mr. Minaldi has said, the FAT is an object with these attributes:<br /><ul><li>Filename (String)
  2. 2. Sectors into which your file’s part are stored (ArrayList/LinkedList/Array/etc, feel free to choose). Make sure the order is correct from start to end.
  3. 3. Size (int/long)</li></ul>Then you make an ArrayList/LinkedList/Array of object FAT. Now you already have all the information you’re needed to add files (identifying whether the sectors has been occupied or not), remove files (keep track all the sectors in order), and listing the files (get the filename and its size then display it onto the screen).<br />How to start it?<br />This is my own way of starting the project. You can follow it or not.<br /><ul><li>Forget about the args[] stuff for now. Better work on the algorithm first: converting, compressing, decompressing, converting back, allocating, collecting, etc.
  4. 4. Make sure you know how to convert files into bytes, and vice versa. TXT files are easier to keep track. If you have succeeded in converting them into array of bytes, you’ll have no difficulty in converting ZIP files into bytes because it uses an exactly same procedure, vice versa.
  5. 5. Make sure you know how to ZIP and UNZIP file. You’ll need to do minor edits from the link I’ve put above.
  6. 6. Start with small size virtual disk, for example 100 bytes. Use TXT files at first (roughly 20-30 bytes). Make sure the TXT can be allocated well throughout the virtual disk (the good thing about using TXT file, you can read it using notepad after being distributed into the Virtual Disk). Or maybe, drawing will help you to understand what I mean:
  7. 7. After all works well, try to implement the FAT. Make your virtual disk bigger. Try to use another files such as JPG, PNG, and others. Good luck!</li></ul>Extra Notes<br /><ul><li>I don’t think Sir Minaldi wants us to use GUI in this project.
  8. 8. Make sure you also use the args[] stuff to run the program cause I think he expects us to use it.
  9. 9. Work with single files only! No need to also consider folder.

×