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
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.
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.
In Javascript,
ESP Game:
Design a program to test your extrasensory perception. The program will randomly pick a card (you could consider only the card suit, for example [Hearts, Diamonds, Clubs, Spades]. ) Prompt the user to enter a suit, then display whether the user guessed correctly.
ESP Game Outcomes:
Modify your ESP game to write the outcome of a game to a file. Allow the user to play the ESP game multiple times, writing each outcome to a file. Then, determine the number of times the user guessed correctly reading from the file.
Please include flowcharts and/or class diagrams.
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 = 60 and F = 450 N, determine the magnitude of the resultant force and its direction, measured counterclock...
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
File Encryption File encryption is the science of writing the contents of a file in a secret code. For this ass...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
T F C++ allows you to create arrays with three or more dimensions.
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
software is generally feature complete, (supposedly) bug free and ready for use by the community.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
What will be the final value of dblResult in the following sequence? Dim dblResult As Double = 3.5 dblResult +=...
Starting Out With Visual Basic (8th 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
- Build a csharp application that reads from a file and print out the contents of that file in another files words by words (i.e. one word each line)arrow_forwardClass Files (package java.nio.file) is one of many classes throughout the Java APIs that have been enhanced to support Streams. State whether the statement is true or false. If false, explain why.arrow_forwardin java' Variables fStream and dataFS are FileInputStream and Scanner, respectively. String fileName is assigned a file's name read from input. Perform the following tasks: Assign fStream with a FileInputStream that opens the file fileName for reading. Assign dataFS with a Scanner created using fStream. Click here for example Ex: If the input is peach2.txt and: Data in file peach2.txt 4.3 then the output is: 4.3 GroceryDataProcessor.java peach1.txt peach2.txt peach3.txt public class GroceryDataProcessor { publicstaticvoidmain(String[] args) throwsIOException { Scannerscnr=newScanner(System.in); StringfileName; doublepeachWeight; FileInputStreamfStream=null; ScannerdataFS=null; fileName=scnr.next(); /* Your code goes here */ peachWeight=dataFS.nextDouble(); System.out.println(peachWeight); fStream.close(); } }arrow_forward
- When using an ObjectlnputStream to read data from a file, what happens when an end-of-file marker is reached? Method readObject returns the value false. An end-of-file character is read by the program. An EOFException is thrown. Nothing special occurs.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_forwardWhy verify a StreamReader object's EndOfStream property before calling ReadLine?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_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_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
- Describe 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_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_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