In this assignment you will use DataInputStreamand DataOutputStream to read and write binary file. You will...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this assignment you will use DataInputStreamand DataOutputStream to read and write binary file. You will also use FileInputStream and FileOutputStream to open the file. Step 1) Using DataOutputStream and FileOutputStream, open a file called Binary.dat. Using a Scanner object and FileReader, open the file Input.txt provided. Input.txt consists of of a set of lines, each of which looks this 2.49 24 carrots The first number is a price, the second a quantity, and the string is the item. Step 2) Read each line of Input.txt (use the nextDouble(), nextInt(), and nextLine() methods of the Scanner. Write the values from each line to Binary.dat using the writeDouble(), writeInt(), and writeUTF() methods of the DataOutputStream. Step 3) Close the DataOutputStream and the Scanner. Step 4) Open Binary.dat for reading using DataInputStream and FileInputStream. Read each of the triples using read Double(), readInt(), and readUTF() of the DataInputStream and display the values using System.out.println(). Input: 2.49 24 carrots 10.99 100 paper cups 5.49 20 premium saltines 3.69 30 eggs 6.79 15 apples 9.99 20 lunch box 4.49 15 ham sandwich In this assignment you will use DataInputStreamand DataOutputStream to read and write binary file. You will also use FileInputStream and FileOutputStream to open the file. Step 1) Using DataOutputStream and FileOutputStream, open a file called Binary.dat. Using a Scanner object and FileReader, open the file Input.txt provided. Input.txt consists of of a set of lines, each of which looks this 2.49 24 carrots The first number is a price, the second a quantity, and the string is the item. Step 2) Read each line of Input.txt (use the nextDouble(), nextInt(), and nextLine() methods of the Scanner. Write the values from each line to Binary.dat using the writeDouble(), writeInt(), and writeUTF() methods of the DataOutputStream. Step 3) Close the DataOutputStream and the Scanner. Step 4) Open Binary.dat for reading using DataInputStream and FileInputStream. Read each of the triples using read Double(), readInt(), and readUTF() of the DataInputStream and display the values using System.out.println(). Input: 2.49 24 carrots 10.99 100 paper cups 5.49 20 premium saltines 3.69 30 eggs 6.79 15 apples 9.99 20 lunch box 4.49 15 ham sandwich
Expert Answer:
Posted Date:
Students also viewed these databases questions
-
C++ Very Important to Read: For program 2 you will be using a string class to read from a file, sort and then output some string . I will give you most of the code for the string class called...
-
Ticket to Ride is a popular board game that involves connecting cities in a given railroad network. In this assignment you will prototype some potential approaches for creating an AI player for this...
-
Glencoe First National Bank operated for years under the assumption that profitability can be increased by increasing dollar volumes. Historically, First Nationals efforts were directed toward...
-
Let P3(x) be the interpolating polynomial for the data (0, 0), (0.5, y), (1, 3), and (2, 2). Use Neville's method to find y if P3(1.5) = 0.
-
A French hotel operator which manages only hotels devoted to the MICE sector ( M eetings, I ncentives, C onventions, E xhibitions) let in August 2017 (term 2029) a 5-star hotel very close to...
-
The built-up shaft consists of a pipe AB and solid rod BC. The pipe has an inner diameter of 25 mm and outer diameter of 30 mm. The rod has a diameter of 15 mm. Determine the average normal stress at...
-
Shawnee Co. set up a petty cash fund for payments of small amounts. The following transactions involving the petty cash fund occurred in May (the last month of the companys fiscal year). May 1...
-
The following selected accounts from the Ivanhoe Corporation's general ledger are presented below for the year ended December 31, 2025: Advertising expense $ 57,000 Interest revenue $ 34,000 Common...
-
Why planning and budgeting are important ? Describe planning process and Variance Analysis and what is the Static and Actual Budget .
-
Can you elucidate the process of germ cell specification and primordial germ cell development during embryogenesis, including the molecular cues and epigenetic modifications that govern germ cell...
-
What is 'the principle of legality' and how does it operate in Australian constitutional law?
-
explain why, as a matter of constitutional law, no civil liberty or right is absolute?
-
How do endocrine glands, such as the pituitary, thyroid, and adrenal glands, orchestrate complex physiological processes through the secretion of hormones, and what are the molecular mechanisms...
-
explain the relationship and significances of the constitutional law of Canada to Jean -Jacques Rousseau the origin and the foundation of the inequality among mankind?
-
1. Predict two (2) trends that are likely to impact public service in the future. Next, choose two (2) leadership competencies that public administrators and nonprofit managers will need to addresses...
-
Prairie Outfitters, Inc., a retailer, accepts paymnent through credit cards. During August, credit card sales amounted to $12,000. The processor charges a 3% fee. Assuming that the credit card...
-
Why is it important to pay attention to cultural differences when interviewing a client?
-
What does the term "unauthorized practice of law" mean, and how does it limit your relationship with a client?
-
Why is it important to acknowledge how a client is feeling at the initial interview?
Study smarter with the SolutionInn App