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.5CP
What will happen if you attempt to create an input stream on a nonexistent file? What will happen if you attempt to create an output stream on an existing file? Can you append data to an existing file?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is the difference between a binary file and a text file? Is it possible to use a text editor to see a text or binary file?
When you say a file is indexed, do you mean it has an index directory that allows for random access?
In what mode do you open a file if you want to write data to it, but you do not want to erase the file’s existing contents? When you write data to such a file, to what part of the file is the data written?
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
A loading causes the block to deform into the dashed shape. Explain how to determine the strains (A) xy, (B)xy....
Mechanics of Materials (10th Edition)
17–1C A high-speed aircraft is cruising in still air. How does the temperature of air at the nose of the aircra...
Thermodynamics: An Engineering Approach
Assume a telephone signal travels through a cable at two-thirds the speed of light. How long does it take the s...
Electric Circuits. (11th Edition)
In Exercises 49 through 54, find the value of the given function. Math.Round(2.6)
Introduction To Programming Using Visual Basic (11th Edition)
Pig Latin Write a program that accepts a sentence as input and converts each word to Pig Latin." In one version...
Starting Out with Python (4th Edition)
State whether each of the following is true or false. If false, explain why. All expression containing the | | ...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
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
- What is the difference between a text and a binary file? Can you use a text editor to see a text or binary file?arrow_forwardWhat is the last action that must be performed on a file with file object f ? Answer:arrow_forwardCan you load the contents of a file into memory without doing any explicit copying?arrow_forward
- Explain in your own words: a.) What does it mean to append data to a file? b.) How do you open a file so that new data will be written to the end of the file’s existing data?arrow_forwardUse C languagearrow_forwardProblem: Encode the file by adding 5 to every byte in the file. Write a program that prompts the useer to enter an input file name and an output file name and saves the encrypted version of the input file to the output file. I don't get any encrypted file. Why? package encrypt; import java.io.*;import java.util.*; public class Encrypt { public static void main(String[] args){ // Input from user Scanner input = new Scanner(System.in); System.out.print("Enter a file to encrupt:"); // Input file from user File inputfile = new File(input.nextLine()); System.out.print("Enter the output file:"); // Output file from user File outputfile = new File(input.nextLine()); try { // Create BufferedInputStream from bis BufferedInputStream bis = new BufferedInputStream (new FileInputStream(inputfile)); // Create BufferedOutputStream from bos…arrow_forward
- Explain the difference between Sequential Files and Random Files? Why is it important to close the File objects after using them in the code?arrow_forwardIf a file already exists what happens to it if you try to open it as an output file (using the 'w' mode)?arrow_forward1.Write a program that reads words from a text file (.txt format) and displays all the nonduplicate words in ascending order. Prepare a words.txt file with your words and pass the file name in the command line. (2 points) 2 .Write a program that reads an unspecified number of integers (unsorted) and finds the one that has the most occurrences. The input ends with the input is 0. (Enter 0 will end the input of the integers value). If several number has the same occurrences, all of them should be reported (output all with equal counts).arrow_forward
- Use Scanner and File to read input from a file. Use PrintStream and File to write output to a file. Write and call methods that accept parameters and return values to manage information flow and add structure to programs. Follow prescribed conventions for spacing, indentation, naming, and comments. Notice that if an input file is not found, either for creating a mad-lib or viewing an existing one, the user is re-prompted. No re-prompting occurs for the output file. If the output file does not already exist, it is created. If it does already exist, its contents are overwritten. (These are the default behaviors in Java.) You may assume that the output file is not the same file as the input file. When you are viewing an existing mad lib story, you are simply reading and echoing its contents to the console. You do not need to do any kind of testing to make sure that the story came from a mad lib input file; just output the file's contents. Menu options can be chosen in any order and are…arrow_forwardWrite a program that writes user input to a text file and then reads the contents from that file. You will need to perform the following steps. Prompt the user for the name of a file to append to and then another prompt for them to enter a sentence. Open the file they requested in append mode and write the user_sentence to this file. Don't forget to close the file when you are done writing to it (explicitly or implicitly). Open the file you just wrote to in read mode and read the contents of the file. Print the complete file contents to the console/shell. Provide comments in your code to explain the logic used. Ensure your program works as expected by testing it with different sentences.arrow_forwardWhat exactly is a file? What is the purpose of "opening" and "closing" a file? What happens if we do it like that?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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