Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 17.7, Problem 17.7.2CP
Create a RandomAccessFi1e stream for the file address.dat to allow the updating of student information in the file. Create a DataOutputStream for the file address.dat. Explain the differences between these two statements.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that generates student records in a database file. Your program should be able to generate at least 10 records. The format in the database should be: student name, student id The first student id should be 20180001, second id will be 20180001 and so forth.
Show screenshot of script
For the code for the txt file.
Dim sw As Streamwriter = File.AppendText(fileName)
I get an error for the file.AppendText(fileName). How do i fix this.
A file has r=20000 STUDENT records of fixed-length. Each record has the following fields: NAME (30 bytes), SSN (10 bytes), ADDRESS (40 bytes), PHONE (9 bytes), BIRTHDATE (8 bytes), SEX (1 byte), MAJORDEPTCODE (4 bytes), MINORDEPTCODE (4 bytes), CLASSCODE (4 bytes, integer), and DEGREEPROGRAM (3 bytes). Suppose the block size is 512 bytes.
(a) Calculate the record size R in bytes.
(b) Calculate the blocking factor (number of tuples per block) and the number of blocks required.
(c) Calculate the average block accesses it takes to find a record by doing a linear search on the file.
(d) Assume the file is ordered by SSN; calculate the block accesses takes to search for a record given its SSN value by doing a binary search.
Chapter 17 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 17.2 - What is a text file and what is a binary file? Can...Ch. 17.2 - How do you read or write text data in Java? What...Ch. 17.3 - Prob. 17.3.1CPCh. 17.3 - How is a Java character represented in the memory,...Ch. 17.3 - If you write the string ABC to an ASCII text file,...Ch. 17.3 - If you write the string 100 to an ASCII text file,...Ch. 17.3 - What is the encoding scheme for representing a...Ch. 17.4 - Prob. 17.4.1CPCh. 17.4 - Why should you always close streams? How do you...Ch. 17.4 - Prob. 17.4.3CP
Ch. 17.4 - Does FileInputStream/Fi1eOutputStream introduce...Ch. 17.4 - What will happen if you attempt to create an input...Ch. 17.4 - How do you append data to an existing text file...Ch. 17.4 - Prob. 17.4.7CPCh. 17.4 - What is written to a file using writeByte(91) on a...Ch. 17.4 - How do you check the end of a file in an input...Ch. 17.4 - What is wrong in the following code? Import...Ch. 17.4 - Suppose you run the following program on Windows...Ch. 17.4 - After the following program is finished, how many...Ch. 17.4 - For each of the following statements on a...Ch. 17.4 - What are the advantages of using buffered streams?...Ch. 17.5 - How does the program check if a file already...Ch. 17.5 - How does the program detect the end of the file...Ch. 17.5 - How does the program count the number of bytes...Ch. 17.6 - Prob. 17.6.1CPCh. 17.6 - Prob. 17.6.2CPCh. 17.6 - Is it true that any instance of...Ch. 17.6 - Prob. 17.6.4CPCh. 17.6 - Prob. 17.6.5CPCh. 17.6 - What will happen when you attempt to run the...Ch. 17.7 - Can RandomAccessFi1e streams read and write a data...Ch. 17.7 - Create a RandomAccessFi1e stream for the file...Ch. 17.7 - What happens if the file test.dat does not exist...Ch. 17 - (Create a text file) Write a program to create a...Ch. 17 - (Create a binary data file) Write a program to...Ch. 17 - (Sum all the integers in a binary data file)...Ch. 17 - (Convert a text file into UTF) Write a program...Ch. 17 - Prob. 17.5PECh. 17 - Prob. 17.6PECh. 17 - Prob. 17.7PECh. 17 - (Update count) Suppose that you wish to track how...Ch. 17 - (Address book) Write a program that stores,...Ch. 17 - (Split files) Suppose you want to back up a huge...Ch. 17 - (Split files GUI) Rewrite Exercise 17.10 with a...Ch. 17 - Prob. 17.12PECh. 17 - (Combine files GUI) Rewrite Exercise 17.12 with a...Ch. 17 - (Encrypt files) Encode the file by adding 5 to...Ch. 17 - (Decrypt files) Suppose a file is encrypted using...Ch. 17 - (Frequency of characters) Write a program that...Ch. 17 - (BitOutputStream) Implement a class named...Ch. 17 - (View bits) Write the following method that...Ch. 17 - (View hex) Write a program that prompts the user...Ch. 17 - (Hex editor) Write a GUI application that lets the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the difference between main memory and secondary storage?
Starting Out With Visual Basic (8th Edition)
ICA 8-64
A 3-volt [V] battery delivers a constant current of 100 milliamperes [mA] to the bulb in a flashlight ...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Suppose f is a function that returns the result of reversing the string of symbols given as its input, and g is...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
List for advantages of SQL-invoked routines.
Modern Database Management
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
Write a function that accepts a list as an argument (assume the list contains integers) and returns the total o...
Starting Out with Python (4th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Create a datafile that contains the first name, last name, gender, age, height, smoking preference, eye color and phone number. Add a variety of records to the file. A sample file looks like:  Write a program that opens the file and reads the records one by one. The program will skip any records where the gender preference is not a match. Of those records that match the gender preference, check to see if the age and height are between the maximum and minum preferences. Then check to see if the smoking preference and eye color are also a match. If at least 3 of the remaining fields match, consider the record a partial match, and print it in the report. If all 4 of the remaining fields match, the record is a perfect match and print it in the report with an asterisk next to it. At the end of the program, close the file and report how many total records there were of the specified gender, how many were a partial match, and how many were a perfect match.arrow_forwardpls don't use AI , chatgpt etc!!!arrow_forwardThe file Scores.txt contains scores of your students. Write ONLY TWO VB.NET INSTRUCTIONS to clone the Scores.txt file to Scores1.txt in the same folder USING IO.FILE METHODS AND ARRAYS: Private Sub btnClone_Click(sender As Object, e As EventArgs) Handles btnClone.Click ………………………… ………………………… End Subarrow_forward
- IOStreams Write a Java program that writes five strings to the file 1ab08.txt, and then reads those five strings back into different variables. The newer versions of Java have changed how they work with file output streams! throws an exception of type FileNotFoundException, and throws an IOException. FileOutputStream DataOutputStream.close() In practice, you won't run into these in the lab. But you do need to call them out when declaring static void main: public static void main(String[] args) throws IOException handles both cases.arrow_forwardDescribe scenarios where you might need to wrap an InputStream with other stream types, such as DataInputStream or BufferedInputStream.arrow_forwardModify the SalesReport2.java program to use the BadData.txt file. You will input integers from this file and continue on if there is a bad record. If a record is bad (nonnumeric), display the file name. Do not just put the filename in quotes, display what file the program used. Change what displays in the catch statements. Add a finally clause. Do something in this clause. See when it is run. Remember: in Eclipse a file must be added to the project, not the src folder. Naming: Name the Java project: LastFProjectAssign09 Name the driver program (main): LastFAssign09.java Where Last is your last name and F is the first initial of your first name. Ex: OgleD Save in a file folder on your storage device SALESREPORT2.JAVA PROGRAM BELOW import java.io.*; // For File class and FileNotFoundExceptionimport java.util.*; // For Scanner and InputMismatchException /** * This program demonstrates how exception handlers can * be used to recover from errors. */public class SalesReport2{public…arrow_forward
- Some Items may correspond to more than one correct choice. In case an item is corresponding to more than one answer, you have to tick on all the correct choices for you to earn the credit allotted for the item.arrow_forwardplease use spyderarrow_forwardThe goal for Lab06b is to use the provided Student class (attached in image) and create an array of Student objects that are stored in a School object(picture of main class attached). This program uses a Student class that is provided and shown below. The class is placed in its own separate file and should not be altered. This program sequence started with Lab06a. It is a reminder that it is the same Student file used by Lab06a. This lab will add data processing to the earlier Lab06a. This program will continue with the Lab06b program that performs some data processing on the Student records. For this lab 10 Student objects need to be constructed and placed in a students array, which is stored in a School object. You actually did this already for Lab06a. You also need to complete the School constructor, addData method and toString Method, which were in Lab06a. Feel free to just copy them over. You need to complete three bubbleSort methods; one that sorts according to the student gpa.,…arrow_forward
- Suppose that you have two text files that contain sequences of integers separated by white space (blank space, tabs, and line breaks). The integers in both files appear in sorted order, with smaller values near the beginning of the file and large values closer to the end. Write a pseudocode algorithm that merges the two sequences into a single sorted sequence that is written to a third file.arrow_forwardFor the part, Dim sw As StreamWriter = File.AppendText(fileName). It says the file isnt declared. Why? and how do I fix this?arrow_forward4. Fast in java coding please. Thank you File Encryption is the science of writing contents of a file in a secret code. Yourencryption program should work like a filter, reading the content of one file,modifying the data into a code, and then writing the coded contents out to a secondfile. The second file will be a version of the first file, but written in secretcode. Write a program to demonstrate the above working with binary files.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License