Different operating systems use different file allocation techniques to store files in the secondary storage device such as HDD. One of the techniques is "Linked allocation". In this technique, each file is divided into several data blocks of same size. Each data block has a link to its next block like a singly linked list. So, the data blocks are scattered on the disk. The directory contains a pointer to the starting and the ending data block of a file. The diagram below depicts a sample linked allocation system of a file Abc.txt: Directory entry File Start End Abc.txt 100 900 Data block 1 Data Data block 3 Data block 2 block N Write a Java program to implement the linked allocation of a given text file Assgn1_2.txt (uploaded with the assignment) who's each block will contain maximum 50 characters. Read the content of the given file and store it in data blocks (maximum 50 characters per block). Now show a menu that will ask the user to )add new content at the end of the list, ii) add new content at any position of the list, ii) print the whole content of the list, iv) print the address of the first data block and the total number of data blocks, and v) Terminate the program You can use the Java in-built LinkedList class to implement the list allocation of the file. You can also use the Scanner class to take inputs from the user. The sample input/ output and the corresponding list structure is given below: (30 points) Sample innut/ outnut:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
1:34 b a
2. Different operating systems use different file allocation techniques to store files in
the secondary storage device such as HDD. One of the techniques is "Linked
allocation". In this technique, each file is divided into several data blocks of same
size. Each data block has a link to its next block like a singly linked list. So, the data
blocks are scattered on the disk. The directory contains a pointer to the starting and
the ending data block of a file. The diagram below depicts a sample linked allocation
system of a file Abc.txt:
Directory entry
File
Start
End
Abc.txt 100
900
Data
900
Data
Data
block 1
block 2
Data
block 3
block N
Write a Java program to implement the linked allocation of a given text file
Assgn1_2.txt (uploaded with the assignment) who's each block will contain
maximum 50 characters. Read the content of the given file and store it in data blocks
(maximum 50 characters per block). Now show a menu that will ask the user to
i) add new content at the end of the list,
ii) add new content at any position of the list,
iii) print the whole content of the list,
iv) print the address of the first data block and the total number of data blocks, and
v) Terminate the program
You can use the Java in-built LinkedList class to implement the list allocation of the
file. You can also use the Scanner class to take inputs from the user. The sample
input/ output and the corresponding list structure is given below:
(30 points)
Sample input/ output:
(Let us assume the content of the given file is:
Linked List allocation solves all problems of contiguous
allocation. In linked list allocation, each file is considered
as the linked list of disk blocks.
The above file content has 154 characters including spaces and punctuations. So,
as per our requirements, four data blocks will be created initially. User's inputs are
shown in bold.)
Enter the file name: Assgn1_2.txt
The list allocation of the file is created in main memory
<The initial list structure is shown below>
Directory entry
File
No_of_blocks
Start
Assgn1_2.txt
100
4
100
Link d L it
allo at ie
solves al
problens of
400
cks.
200
300
iguous
allocation. In
linked list
allocation,
each
file is
considered as
the linked
list of disk
cont
blo
Transcribed Image Text:1:34 b a 2. Different operating systems use different file allocation techniques to store files in the secondary storage device such as HDD. One of the techniques is "Linked allocation". In this technique, each file is divided into several data blocks of same size. Each data block has a link to its next block like a singly linked list. So, the data blocks are scattered on the disk. The directory contains a pointer to the starting and the ending data block of a file. The diagram below depicts a sample linked allocation system of a file Abc.txt: Directory entry File Start End Abc.txt 100 900 Data 900 Data Data block 1 block 2 Data block 3 block N Write a Java program to implement the linked allocation of a given text file Assgn1_2.txt (uploaded with the assignment) who's each block will contain maximum 50 characters. Read the content of the given file and store it in data blocks (maximum 50 characters per block). Now show a menu that will ask the user to i) add new content at the end of the list, ii) add new content at any position of the list, iii) print the whole content of the list, iv) print the address of the first data block and the total number of data blocks, and v) Terminate the program You can use the Java in-built LinkedList class to implement the list allocation of the file. You can also use the Scanner class to take inputs from the user. The sample input/ output and the corresponding list structure is given below: (30 points) Sample input/ output: (Let us assume the content of the given file is: Linked List allocation solves all problems of contiguous allocation. In linked list allocation, each file is considered as the linked list of disk blocks. The above file content has 154 characters including spaces and punctuations. So, as per our requirements, four data blocks will be created initially. User's inputs are shown in bold.) Enter the file name: Assgn1_2.txt The list allocation of the file is created in main memory <The initial list structure is shown below> Directory entry File No_of_blocks Start Assgn1_2.txt 100 4 100 Link d L it allo at ie solves al problens of 400 cks. 200 300 iguous allocation. In linked list allocation, each file is considered as the linked list of disk cont blo
Enter your choice: 3
The latest content of the file:
Linked List allocation solves all problems of contiguous allocation. In linked list
allocation, each file is considered as the linked list of disk blocks.
Enter your choice: 1
Enter the new content: However, the disks blocks allocated to a particular file
need not to be contiguous on the disk.
The new content has been added at the end of the list allocation structure.
<The modified list structure is shown below>
Directory entry
File
Start
No of blocks
Assgn1_2.txt
100
5
100
Linked List
200
allocation
soives al2
problems of
snons
allocation. Id
file is
considered as
the linked
list of diek
400
cks. However,
500
ar file need
linked list
allocation,
esch
the disks
not to be
blocks
contiguous on
the disk.
cont
allocsted to
blo
particui
Enter your choice: 2
After which sentence you want to insert a new line (number only): 2
Enter the new line: The directory entry contains the starting and ending location
of the data blocks.
The new content has been added after the 2nd line.
<The modified list structure is shown below>
Directory entry
File
Start
No_of_blocks
Assgn1_2.txt
100
8
200
1guous
allocation. In
Liakod Liet
file ia
considered aa
allocation
cks.
solves al
problens of
ar file need
not to be
contiguous od
lirked list
the linked
allocation,
list of disk
blo
cont
each
h
the disk.
700
ng location
of the data
600
The directory
800
entry containa
the starting
and endi
However, the
disks blocks
allocated to
a particul
blocks.
Enter your choice: 3
The latest content of the file:
Linked List allocation solves all problems of contiguous allocation. In linked list
allocation, each file is considered as the linked list of disk blocks. The directory entry
contains the starting and ending location of the data blocks. However, the disks
blocks allocated to a particular file need not to be contiguous on the disk.
Enter your choice: 4
Address of the first block: 100
Total number of blocks: 8
Enter your choice: 5
Thank you!
Transcribed Image Text:Enter your choice: 3 The latest content of the file: Linked List allocation solves all problems of contiguous allocation. In linked list allocation, each file is considered as the linked list of disk blocks. Enter your choice: 1 Enter the new content: However, the disks blocks allocated to a particular file need not to be contiguous on the disk. The new content has been added at the end of the list allocation structure. <The modified list structure is shown below> Directory entry File Start No of blocks Assgn1_2.txt 100 5 100 Linked List 200 allocation soives al2 problems of snons allocation. Id file is considered as the linked list of diek 400 cks. However, 500 ar file need linked list allocation, esch the disks not to be blocks contiguous on the disk. cont allocsted to blo particui Enter your choice: 2 After which sentence you want to insert a new line (number only): 2 Enter the new line: The directory entry contains the starting and ending location of the data blocks. The new content has been added after the 2nd line. <The modified list structure is shown below> Directory entry File Start No_of_blocks Assgn1_2.txt 100 8 200 1guous allocation. In Liakod Liet file ia considered aa allocation cks. solves al problens of ar file need not to be contiguous od lirked list the linked allocation, list of disk blo cont each h the disk. 700 ng location of the data 600 The directory 800 entry containa the starting and endi However, the disks blocks allocated to a particul blocks. Enter your choice: 3 The latest content of the file: Linked List allocation solves all problems of contiguous allocation. In linked list allocation, each file is considered as the linked list of disk blocks. The directory entry contains the starting and ending location of the data blocks. However, the disks blocks allocated to a particular file need not to be contiguous on the disk. Enter your choice: 4 Address of the first block: 100 Total number of blocks: 8 Enter your choice: 5 Thank you!
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY