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.4, Problem 17.4.12CP
After the following program is finished, how many bytes are there in the file t.dat? Show the contents of each byte.
import java.io.*;
public class Test {
public static void main(String[] args) throws IOException {
try (DataOutputStream output = new DataOutputStream(
new FileOutputStream(“t.dat”)); ) {
output.writeInt(1234);
output.writeInt(5678);
output.close() ;
}
}
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a Java program
Write a python code that reads a file (contents of the file pasted below) and shows the average
of all values shown in the last column.
File Name: data.txt
File Contents (of data.txt):
Admin 100 300 tmp 20
Admin 100 300 tmp 30
Admin 100 300 tmp 20
Admin 100 300 tmp 10
Admin 100 300 tmp 60
Admin 100 300 tmp 95
Admin 100 300 tmp 100
Admin 100 300 tmp 24
Admin 100 300 tmp 99
Admin 100 300 tmp 50
Use Java program
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
Create a flowchart that shows the necessary steps for making the cookies in the following recipe: Ingredients: ...
Starting Out With Visual Basic (8th Edition)
Modify the Product_T table by adding an attribute QtyOnHand that can be used to track the finished goods invent...
Modern Database Management
The following is an old word puzzle: Name a common word, besides tremendous, stupendous, and horrendous, that e...
Java: An Introduction to Problem Solving and Programming (8th Edition)
A picture is taken of a man performing a pole vault, and the minimum radius of curvature of the pole is estimat...
Mechanics of Materials (10th Edition)
A file that contains a Flash animation uses the __________ file extension. a. .class b. .swf c. .mp3 d. .flash
Web Development and Design Foundations with HTML5 (8th Edition)
Why is the study of database technology important?
Database Concepts (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
- Insert the missing code in the following code fragment. This fragment is intended to read an input file. public static void main(String[] args) String inputFileName = "dataIn.txt"; File inputFile = new File(inputFileName); Scanner in = new Scanner(inputFile); Select one: Oa. throws FileNotFoundException b. inherits FileNotFoundException C. catches FileNotFoundException O d. extends FileNotFoundException Next pag A 1 ENGarrow_forwardPlease answer and write algorithmarrow_forwardjava pleasearrow_forward
- write java programarrow_forwardModify the code so that it writes the contents of String[] into a file named fileLoop1.txt CODE import java.util.Scanner; import java.io.*; public class Stringio { public static void main(String[] args) throws IOException { File loopfile = new File("fileLoop.txt"); Scanner getAll = new Scanner( loopfile ); String num; String[] items = new String[10]; int i = 0; while(getAll.hasNextLine()){ num = getAll.nextLine(); // square = num * num ; //System.out.println("The square of " + num + " is " + square); items[i] = num; System.out.println("items[i] is " + items[i]); i = i + 1; } getAll.close(); } }arrow_forwardJava program involves the use of Strings, characters and file I/O.arrow_forward
- Using Python: Write a program that inputs a text file then counts the unique words in the file. Output each unique word and the number of times it occurs in the input file. Remove any spaces and punctuation from the data and convert each word to lowercase. https://rose.instructure.com/courses/11779/files/1799063? verifier=PeDzy 7Z2p3NhCztKp6oaEJKkUa0z7vmWRyWQFchh&wrap=1 Sample Output: a 7 above 1 add 1 advanced 1 ago 1 all 1 altogether 1 and 6 any 1 are 3arrow_forwardUsing Python: Write a program that inputs a text file then counts the unique words in the file. Output each unique word and the number of times it occurs in the input file. Remove any spaces and punctuation from the data and convert each word to lowercase. https://rose.instructure.com/courses/11779/files/1799063?verifier=PeDzy7Z2p3NhCztKp6oaEJKkUa0z7vmWRyWQFchh&wrap=1 Sample Output: a 7 above 1 add 1 advanced 1 ago 1 all 1 altogether 1 and 6 any 1 are 3arrow_forwardWrite a program that reads a file containing two columns of floating-point numbers Prompt the user of the file name.Print the average of each column. javaarrow_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
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License