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.1CP
Can RandomAccessFi1e streams read and write a data file created by DataOutputStream? Can RandomAccessFile streams read and write objects?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a program that writes an Integer object to a stream and reads this object from the stream.
You would use a stream's clear method to:
Multiple answers: Multiple answers are accepted for this question
a empty the output buffer
b reset flags after a failed translation/extraction
c clear the screen
d clean up after a bad file open attempt
e forget an end-of-file encounter before seeking back to the beginning of the stream
Assume inputFile references a StreamReader object that is associated with an open file. Which of the following loops is written in the correct general format to read all of the items from the file? Loop A: while (inputFile.EndOfStream) { // Read an item from the file. } Loop B: while (!inputFile.EndOfStream) { // Read an item from the file. }
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
If the period of a pulse waveform increases, the frequency also increases.
Digital Fundamentals (11th Edition)
Assume as known that the Vandermonde determinant V=|11...1r1r2...r3r12r22...rn2r1n1r2n1...rnn1| is nonzero if t...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
The following program skeleton determines whether a person qualifies for a credit card. To qualify, the person ...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Give an example of each of the following, other than those described in this chapter, and clearly explain why y...
Modern Database Management (12th Edition)
Which file open flag causes all output to take place at the end of the file?
Starting Out with C++: Early Objects (9th Edition)
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts of Programming Languages (11th 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
- PrintWriter and Scanner - text file I/O DataInputStream and DataOutputStream - binary file I/O RandomAccessFile - binary file i/o where every record is the same number of bytes so that you can seek to a specific record ObjectInputStream and ObjectOutputStream - read and write objects.arrow_forwardThe teacher at a school needs help grading an exam with a number of True/False questions. The students’ IDs and test answers are stored in a file. The first entry of the file contains the answer to the test in the form: TTFTFTTTFTFTFFTTFTTF Every other entry in the file is the student’s ID, followed by a blank, followed by the students’ response. For instance, the entry: ABC54102 T FTFTFTTTFTTFTTF TF The student’s ID is ABC54102, answer to question 1 is True, the answer to question 3 is False. Also, the student did not answer question 2 and question 18. The exam has 20 questions. Here is the grading policy: each correct answer is awarded two points, each wrong answer get -1 point, and no answer gets 0 point. Write a program that processes the test data. The output should be the student’s ID, followed by the answers, followed by the test score (total points), followed by the test grade. Assume the following grade scale will be used: 90%-100%, A; 80%-89.99%, B; 70%-79.99%, C; 60%-69.99%,…arrow_forwardUsing only BufferedReader and BufferedWriter to read/write files and only arrays for any data structure needs, create a static method reverseLineOrder which accepts the arguments: Filename to the input file as a String Filename of the output file as a String The method will create a new file with the lines from the given data set in reverse order. Data.txt: 1 2 3 4 5 6 7 8 9 0 9 8 7 6 5 4 3 2 1 0 8 7 6 5 4 3 2 1 0 9 Subject: Java Programmingarrow_forward
- I need help with my code i need to ask the user for a filename. Display the oldest car for every manufacturer from that file. If two cars have the same year, compare based on the VIN. my code is not working properly, it is just dipslaying exactly what is in the file that the user inputs here is the code import java.io.BufferedReader;import java.io.FileReader;import java.util.Comparator;import java.io.File;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.Collections;import java.util.Scanner;class Car {private String makeModel;private int year;private String VIN;public Car(String makeModel, int year, String VIN) {this.makeModel = makeModel;this.year = year;this.VIN = VIN;}public String getMakeModel() {return makeModel;}public int getYear() {return year;}public String getVIN() {return VIN;}}class Assignment8_2 {private static int minIndex(ArrayList<Car> cars, int i, int j) {if (i == j)return i;int k = minIndex(cars, i + 1, j);if…arrow_forwardDescribe the advantages of using a FileInputStream over a FileReader when dealing with binary data.arrow_forwardGiven a valid file object, f, which of the following calls will return the entire contents of the file in a scalar x? x = f.readline() x = f.readlines() x = f.read() X = read(f)arrow_forward
- What is the error in readFile()? publicvoidreadFile(){FileInputStream fbStream = null; Scanner inFS = null; int value = 0; fbStream = new FileInputStream("data.txt");inFS = new Scanner(fbStream);value = inFS.nextInt();System.out.println("Value: " + value);fbStream.close(); } a. There is a data input mismatch b. readFile( ) does not throw IOException c. inFS is not closed d. The code has no errors JAVAarrow_forwardWrite a program that prompts the user for an input file name, reads all words from the input file, and writes the words to the output file sentences.txt. Start a new line whenever a word ends in a period, question mark, or exclamation mark. Complete the following file: sentences.cpp 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { fstream file; ofstream fout; 8. 9 10 string character; cout > input_file_name; 11 12 13 14 file.open(input_file_name.c_str()); fout.open("sentences.txt"); while(file >> character) { for(int i = 0;iarrow_forwardYou develop a Python application for your school. You need to read and write data to a text file. If the file does not exist, it must be created. If the file has content, the content must be removed. Which code should you use? Group of answer choices open(“local_data”, “r”) open(“local_data”, “w+”) open(“local_data”, “r+”) D. open(“local_data”, “w”)arrow_forwardWhich is true? a. The FileOutputStream class includes println( ) b. A PrintWriter object should be closed using close( ) c. A PrintWriter constructor requires an OutputStream object d. A FileOutputStream object opens an existing file JAVAarrow_forwardThe getSelectedFile method of a JFileChooser object returns a File object. What exactly is this File object? A string containing a file name, a disk file, something else?arrow_forwardDoes the class FileOutputStream have a constructor that accepts a filename as an argument?arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
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