Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 17.4, Problem 17.4.4CP
Does FileInputStream/Fi1eOutputStream introduce any new methods beyond the methods inherited from InputStream/OutputStream? How do you create a FileInputStream/Fi1eOutputStream?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Is there a rationale between naming many operations in iostream and fstream the same thing? When can we safely recycle function names?
Write a complete program that uses an ifstream object to read integers from a file called numbers.txt, and an ofstream object to write into a file called evens.txt.Your program should have loop that reads each integer from the input file, then writes it into the output file if it is an even number. Write each even number in na separate line.Make sure to close both files before your program terminates.
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.
Chapter 17 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global 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
?.1 Define the different reference meridians that can be used for the direction ofa line.
Elementary Surveying: An Introduction To Geomatics (15th Edition)
ICA 8-57
A 100-watt [W] motor (60% efficient) is available to raise a load 5 meters [m] into the air. If the ta...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
What output is produced by the following code?
Java: An Introduction to Problem Solving and Programming (8th Edition)
List the functions of a database application.
Database Concepts (8th Edition)
Consider the example code shown in Figure 7-10. What changes would you need to make to ensure that the applicat...
Modern Database Management
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (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
- You are a cyber investigator, your task is to write a python program that can read file signatures from a file and save them into a list. Each file signature is an element of your list. Then, try to find out if there is a JPG file in there. If there is a JPG file, print out a True on screen. (File Signature for JPG file is: FF D8 FF DB) The input file is: FSCS360_Midterm_Exam_Part2.txtarrow_forwardWrite a complete program that uses an ifstream object to read integers from a file called numbers.txt, and an ofstream to write into a file called doubles.txtYour program should have a loop that reads five integers from the input file, then writes the doouble of each (x2) into the input file. Write each value in a separate line.Make sure to close both files before your program terminates.arrow_forwardWhat's the big deal about calling ReadLine on a StreamReader object without first verifying its EndOfStream property?arrow_forward
- Write a test client which takes a file path as an argument and reads each line one by one. The file can contain any number of DNA sequences (i.e., Strings.). After reading each DNA sequence, your code should print the DNA sequence first. Please follow the screenshot below for the output format. If the DNA sequence is valid DNA, report that and print out its complement as well as whether or not it is a Watson-Crick complemented palindrome. If the DNA sequence is not a valid DNA, only report that. Continue this process for each DNA sequence in the text file. Separate the outputs for each sequence by printing a line as shown in the screenshot. In your project directory, create a new directory named ‘in’. The in folder will contain the input text file, titled sequences.txt. To run the code, your program argument should be in/sequences.txt Method Summary. Return Type Method 1 boolean isValid(String DNA) 2 String…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_forwardBuild 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_forward
- What is the return type for the method readObject of the classObjectInputStream?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_forwardpls don't use AI , chatgpt etc!!!arrow_forward
- b) When writing objects using an ObjectOutputStream some data members cannot be written. Which data members cannot be serialized?arrow_forwardSome 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_forwardwhat is ifstream class ?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
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