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
Concept explainers
Textbook Question
Chapter 17.4, Problem 17.4.9CP
How do you check the end of a file in an input stream (FileInputStream, DataInputStream)?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In Python
Write a program that reads the contents of a text file and inserts the line numbers at the beginning of each line, then rewrites the file contents
Write a C# program that reads a text file and outputs the contains to the screen. The text file should be created outside of your code.
Your program should do the following:
Create a StreamReader that will read your text file
for example
// Open the input file for reading
using (StreamReader reader = new StreamReader("input.txt"))
Output each line from the text file
Output one last line that says: "THE END OF FILE"
Explain the nature of the StreamWriter object.
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
When a file that already exists is opened in append mode, the file's existing contents are erased.
Starting Out with Programming Logic and Design (4th Edition)
Efficient Computation of Fibonacci Numbers Modify the application in Code Listing 16-18 by replacing the recurs...
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
The spreadsheet in Microsoft Excel file Ch01Ex01_U10e.xlsx contains records of employee activity on special pro...
Using MIS (10th Edition)
Run the hello, world program on your system. Experiment with leaving out parts of the program, to see what erro...
C Programming Language
The decimal number system is a weighted system with ten digits.
Digital Fundamentals (11th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th 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 new file (in Dev C++) In Lab 2, you created a menu for a simple calculator program. In Lab 6, you added some functionality based on the user selection. In this lab, you will add some more functionality to the program. Use loops to keep running the program until the user chooses the exit condition (9). When dividing, use a loop to validate user input, making sure the denominator (second number) is not zero. If the user enters a 0 for the second number, display an error message and keep prompting until a non-zero number is entered. 1) Add two numbers 2) Subtract two numbers 3) Multiply two numbers 4) Divide two numbers 9) Exit program The program should: contain header comments as shown in class display a hello message before presenting the menu display the menu prompt user for selection echo the selection back to the user if the selection was invalid, display error message to user and then loop back to menu if the selection was valid, prompt the user for two numbers…arrow_forwardwhat is ifstream file ?arrow_forwardPlease Use Pythonarrow_forward
- If your program needs to read data from a file, but the file does not exist, an error would occur when running this program. What kind of error is this?arrow_forwardWhat factors may cause an input stream to fail? When an input stream reaches the fail condition, what happens next?arrow_forwardPlease do this in Python: Write a program that allows the user to navigate lines of text in a file. The program should prompt the user for a filename, read the file and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line number range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the text associated with that number.arrow_forward
- Program that reads a string from the user and append it into a file.arrow_forwardPlease write a program that reads the file, then removes any missing data and prints it out. You should be able to see a DataFrame like the one below:arrow_forwardYou are given a filename. Read the names in the file and output only the initials. For example, if the filename is "data.txt", and the file content in "data.txt" is Dumond, Kristin Larson, Lois the output should be: KD LLarrow_forward
- Your ReadRoomFile program reads a room file. Is it possible to tell how many rooms are in the file from the file size? Explain why or why not?arrow_forwardJAVA PPROGRAM Write a program that prompts the user to enter a file name, then opens the file in text mode and reads names. The file contains one name on each line. The program then compares each name with the name that is at the end of the file in a symmetrical position. For example if the file contains 10 names, the name #1 is compared with name #10, name #2 is compared with name #9, and so on. If you find matches you should print the name and the line numbers where the match was found. While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name. The file may contain up to 100 names. You can use an array or ArrayList object of your choosing, however you can only have one array or ArrayList. Input validation: a) If the file does not exist, then you should display a message "File 'somefile.txt' is not found." and allow the…arrow_forwardWrite program that reads a list of names from a data file and displays the names to the console. The program should prompt the user to enter a filename. Create such a file and check your code. Solve with python. Example of code format: #Prompt the user for file name file_name = input("Enter file name : ") #Open file with open(file_name,"r") as file: #Read file content f = file.readline() #split the contents into numbers numbers = f.split(' ') test_list = [int(i) for i in numbers] res = 1 #Find the product for i in test_list: res*=i #Print result print("Product of numbers in the list :",res)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Linux - Tutorial for Beginners in 13 MINUTES! [ UPDATED ]; Author: bai;https://www.youtube.com/watch?v=BMGixkvJ-6w;License: Standard YouTube License, CC-BY
What is Linux?; Author: Techquickie;https://www.youtube.com/watch?v=zA3vmx0GaO8;License: Standard YouTube License, CC-BY
Introduction to Linux and Basic Linux Commands for Beginners; Author: sakitech;https://www.youtube.com/watch?v=IVquJh3DXUA;License: Standard Youtube License