SlideShare a Scribd company logo
37.11 File Random Access
In this program you will use RandomAccessFile to read and write a binary file (Binary.dat).
Step 1) Create a RandomAccessFile object for the Binary.dat file. Use the 'rws' tag to ensure that
changes happen immediately. Create a ArrayList of type Long as well.
Stepl 2) The data in Binary.dat is organized logically as sets of triples: a price (double, 8 bytes),
an amount (int, 4 bytes), and a description (UTF string, indefinite). Use the readDouble(),
readInt(), and readUTF() methods of RandomAccessFile to read these triples until the end of the
file is reached. The most straightforward way to do this is to get the length of Binary.dat ( use
the length() method of RandomAccessFile ) before the loop and then repeat the loop as long as
the current position ( use getFilePointer() of RandAccessFile to get this ) is less than the file
length. After you read each triple, display the values on a line separate by a space and also save
the current file position on the ArrayList (use the RandomAccessFile method getFilePointer() to
get the current file position). You program should display the following:
Submit your code to pass Test 1.
Step 3)
Write a loop that goes through the Binary.dat file and increases all of the prices by 5%. You will
need to use the seek() and writeDoublle() of RandomAccessFile. The values that you saved in
the ArrayList will be helpful. Submit your code. to pass Test 2.
import java.io.*;
import java.util.*;
public class FileRandomAccess {
public static void main(String [] args) {
/* Replace this comment with your code. */
}
}
37-11 File Random Access In this program you will use RandomAccessFile.docx

More Related Content

Similar to 37-11 File Random Access In this program you will use RandomAccessFile.docx

15. Streams Files and Directories
15. Streams Files and Directories 15. Streams Files and Directories
15. Streams Files and Directories
Intro C# Book
 
Text Mining with R
Text Mining with RText Mining with R
Text Mining with R
Sanjay Mishra
 
File management in C++
File management in C++File management in C++
File management in C++
apoorvaverma33
 
File handling4.pdf
File handling4.pdfFile handling4.pdf
File handling4.pdf
sulekha24
 
File handling3.pdf
File handling3.pdfFile handling3.pdf
File handling3.pdf
nishant874609
 
working with files
working with filesworking with files
working with files
SangeethaSasi1
 
Data file handling
Data file handlingData file handling
Data file handling
Prof. Dr. K. Adisesha
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
Barry DeCicco
 
1
11
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
theodorelove43763
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
mary772
 
Files.pptx
Files.pptxFiles.pptx
Files.pptx
Govardhan Bhavani
 
Apache tika
Apache tikaApache tika
Unix-module3.pptx
Unix-module3.pptxUnix-module3.pptx
Unix-module3.pptx
ssuser8594b8
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handlingpinkpreet_kaur
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handlingpinkpreet_kaur
 
Lab 1 Essay
Lab 1 EssayLab 1 Essay
Lab 1 Essay
Melissa Moore
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
Mahmoud Ouf
 

Similar to 37-11 File Random Access In this program you will use RandomAccessFile.docx (20)

15. Streams Files and Directories
15. Streams Files and Directories 15. Streams Files and Directories
15. Streams Files and Directories
 
Text Mining with R
Text Mining with RText Mining with R
Text Mining with R
 
Lucece Indexing
Lucece IndexingLucece Indexing
Lucece Indexing
 
File management in C++
File management in C++File management in C++
File management in C++
 
File handling4.pdf
File handling4.pdfFile handling4.pdf
File handling4.pdf
 
File handling3.pdf
File handling3.pdfFile handling3.pdf
File handling3.pdf
 
working with files
working with filesworking with files
working with files
 
Data file handling
Data file handlingData file handling
Data file handling
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
 
1
11
1
 
Filehandling
FilehandlingFilehandling
Filehandling
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docxCMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
 
Files.pptx
Files.pptxFiles.pptx
Files.pptx
 
Apache tika
Apache tikaApache tika
Apache tika
 
Unix-module3.pptx
Unix-module3.pptxUnix-module3.pptx
Unix-module3.pptx
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handling
 
Lab 1 Essay
Lab 1 EssayLab 1 Essay
Lab 1 Essay
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 

More from HarryyQZColemane

28- Which of the following infectious agents has the smallest genome s.docx
28- Which of the following infectious agents has the smallest genome s.docx28- Which of the following infectious agents has the smallest genome s.docx
28- Which of the following infectious agents has the smallest genome s.docx
HarryyQZColemane
 
2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx
2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx
2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx
HarryyQZColemane
 
2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx
2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx
2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx
HarryyQZColemane
 
2-Draw and list one of the many estuaries visible on the map- list the.docx
2-Draw and list one of the many estuaries visible on the map- list the.docx2-Draw and list one of the many estuaries visible on the map- list the.docx
2-Draw and list one of the many estuaries visible on the map- list the.docx
HarryyQZColemane
 
22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx
22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx
22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx
HarryyQZColemane
 
2- Suppose you are planning to build a fence for your backyard- You ha.docx
2- Suppose you are planning to build a fence for your backyard- You ha.docx2- Suppose you are planning to build a fence for your backyard- You ha.docx
2- Suppose you are planning to build a fence for your backyard- You ha.docx
HarryyQZColemane
 
2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx
2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx
2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx
HarryyQZColemane
 
2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx
2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx
2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx
HarryyQZColemane
 
2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx
2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx
2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx
HarryyQZColemane
 
22- SATA Which of the following is-are the reason(s) that DNA is more.docx
22- SATA Which of the following is-are the reason(s) that DNA is more.docx22- SATA Which of the following is-are the reason(s) that DNA is more.docx
22- SATA Which of the following is-are the reason(s) that DNA is more.docx
HarryyQZColemane
 
23- Per the Supreme Court's holding in Katz v- United States- which tw.docx
23- Per the Supreme Court's holding in Katz v- United States- which tw.docx23- Per the Supreme Court's holding in Katz v- United States- which tw.docx
23- Per the Supreme Court's holding in Katz v- United States- which tw.docx
HarryyQZColemane
 
24- Areas of continued cell division throughout a plant's hife are kno.docx
24- Areas of continued cell division throughout a plant's hife are kno.docx24- Areas of continued cell division throughout a plant's hife are kno.docx
24- Areas of continued cell division throughout a plant's hife are kno.docx
HarryyQZColemane
 
4- Define a Python function named plot sine to sketch the 2-D graph (p.docx
4- Define a Python function named plot sine to sketch the 2-D graph (p.docx4- Define a Python function named plot sine to sketch the 2-D graph (p.docx
4- Define a Python function named plot sine to sketch the 2-D graph (p.docx
HarryyQZColemane
 
4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx
4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx
4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx
HarryyQZColemane
 
4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx
4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx
4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx
HarryyQZColemane
 
4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx
4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx
4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx
HarryyQZColemane
 
39- Federal wiretap laws primarily protect what type of information- A.docx
39- Federal wiretap laws primarily protect what type of information- A.docx39- Federal wiretap laws primarily protect what type of information- A.docx
39- Federal wiretap laws primarily protect what type of information- A.docx
HarryyQZColemane
 
34) In this forecasting technique- care should be taken to make sure t.docx
34) In this forecasting technique- care should be taken to make sure t.docx34) In this forecasting technique- care should be taken to make sure t.docx
34) In this forecasting technique- care should be taken to make sure t.docx
HarryyQZColemane
 
2- Pegged exchange rate systems A country may find it difficult to mai.docx
2- Pegged exchange rate systems A country may find it difficult to mai.docx2- Pegged exchange rate systems A country may find it difficult to mai.docx
2- Pegged exchange rate systems A country may find it difficult to mai.docx
HarryyQZColemane
 
3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx
3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx
3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx
HarryyQZColemane
 

More from HarryyQZColemane (20)

28- Which of the following infectious agents has the smallest genome s.docx
28- Which of the following infectious agents has the smallest genome s.docx28- Which of the following infectious agents has the smallest genome s.docx
28- Which of the following infectious agents has the smallest genome s.docx
 
2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx
2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx
2-4 Jomens Ltd also owns shares in other listed companies- such as Mic.docx
 
2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx
2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx
2- Snakes- which lack limbs- evolved from vertebrates that had legs- E.docx
 
2-Draw and list one of the many estuaries visible on the map- list the.docx
2-Draw and list one of the many estuaries visible on the map- list the.docx2-Draw and list one of the many estuaries visible on the map- list the.docx
2-Draw and list one of the many estuaries visible on the map- list the.docx
 
22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx
22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx
22) Luther Corporation Refer to the balance sheet above- What is Luthe.docx
 
2- Suppose you are planning to build a fence for your backyard- You ha.docx
2- Suppose you are planning to build a fence for your backyard- You ha.docx2- Suppose you are planning to build a fence for your backyard- You ha.docx
2- Suppose you are planning to build a fence for your backyard- You ha.docx
 
2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx
2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx
2- Sickle-cell anemia is an interesting genetic disease- Normal homozy.docx
 
2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx
2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx
2-15- Table 2-8 gives data on expenditure on food and total expenditur.docx
 
2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx
2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx
2- Wropathogenic Escherichia coli is isolated from patient A (who is d.docx
 
22- SATA Which of the following is-are the reason(s) that DNA is more.docx
22- SATA Which of the following is-are the reason(s) that DNA is more.docx22- SATA Which of the following is-are the reason(s) that DNA is more.docx
22- SATA Which of the following is-are the reason(s) that DNA is more.docx
 
23- Per the Supreme Court's holding in Katz v- United States- which tw.docx
23- Per the Supreme Court's holding in Katz v- United States- which tw.docx23- Per the Supreme Court's holding in Katz v- United States- which tw.docx
23- Per the Supreme Court's holding in Katz v- United States- which tw.docx
 
24- Areas of continued cell division throughout a plant's hife are kno.docx
24- Areas of continued cell division throughout a plant's hife are kno.docx24- Areas of continued cell division throughout a plant's hife are kno.docx
24- Areas of continued cell division throughout a plant's hife are kno.docx
 
4- Define a Python function named plot sine to sketch the 2-D graph (p.docx
4- Define a Python function named plot sine to sketch the 2-D graph (p.docx4- Define a Python function named plot sine to sketch the 2-D graph (p.docx
4- Define a Python function named plot sine to sketch the 2-D graph (p.docx
 
4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx
4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx
4- Consider variance stabilized transformation on Y- Suppose 2(Xi)-10(.docx
 
4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx
4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx
4- Answer the following- Show all your work- (a) Let X be a Poisson ra.docx
 
4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx
4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx
4- (21 Points) Norman Osborn- the founder and CEO of Oscorp- has been.docx
 
39- Federal wiretap laws primarily protect what type of information- A.docx
39- Federal wiretap laws primarily protect what type of information- A.docx39- Federal wiretap laws primarily protect what type of information- A.docx
39- Federal wiretap laws primarily protect what type of information- A.docx
 
34) In this forecasting technique- care should be taken to make sure t.docx
34) In this forecasting technique- care should be taken to make sure t.docx34) In this forecasting technique- care should be taken to make sure t.docx
34) In this forecasting technique- care should be taken to make sure t.docx
 
2- Pegged exchange rate systems A country may find it difficult to mai.docx
2- Pegged exchange rate systems A country may find it difficult to mai.docx2- Pegged exchange rate systems A country may find it difficult to mai.docx
2- Pegged exchange rate systems A country may find it difficult to mai.docx
 
3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx
3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx
3- Two haploid gametes come together to form a diploid zygote- 3a- How.docx
 

Recently uploaded

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 

Recently uploaded (20)

Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 

37-11 File Random Access In this program you will use RandomAccessFile.docx

  • 1. 37.11 File Random Access In this program you will use RandomAccessFile to read and write a binary file (Binary.dat). Step 1) Create a RandomAccessFile object for the Binary.dat file. Use the 'rws' tag to ensure that changes happen immediately. Create a ArrayList of type Long as well. Stepl 2) The data in Binary.dat is organized logically as sets of triples: a price (double, 8 bytes), an amount (int, 4 bytes), and a description (UTF string, indefinite). Use the readDouble(), readInt(), and readUTF() methods of RandomAccessFile to read these triples until the end of the file is reached. The most straightforward way to do this is to get the length of Binary.dat ( use the length() method of RandomAccessFile ) before the loop and then repeat the loop as long as the current position ( use getFilePointer() of RandAccessFile to get this ) is less than the file length. After you read each triple, display the values on a line separate by a space and also save the current file position on the ArrayList (use the RandomAccessFile method getFilePointer() to get the current file position). You program should display the following: Submit your code to pass Test 1. Step 3) Write a loop that goes through the Binary.dat file and increases all of the prices by 5%. You will need to use the seek() and writeDoublle() of RandomAccessFile. The values that you saved in the ArrayList will be helpful. Submit your code. to pass Test 2. import java.io.*; import java.util.*; public class FileRandomAccess { public static void main(String [] args) { /* Replace this comment with your code. */ } }