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() ;
}
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Programming in C
Starting Out With Visual Basic (8th Edition)
Starting Out with Python (4th Edition)
- Write a program that reads 5 integer numbers from a file"integer.txt",and store sum and average in "result.txt".arrow_forwardhere solution for part a pls give solution for part b, c, d import java.io.*;public class CopyFile { public static void main(String args[]) throws IOException { FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream("input.txt"); out = new FileOutputStream("output.txt"); int c; while ((c = in.read()) != -1) { out.write(c); } }finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } }arrow_forwardDescribe the advantages of using a FileInputStream over a FileReader when dealing with binary data.arrow_forward
- Write a Java Program to perform the following operations using FileOutputStream andFileInputStream classes To Read the Content and Write the Content into a File To Count the Number of Lines in a file To Count the Number of Vowels and Consonants from a File To Count the Number of Words from a File Read a character from a file and check its case. If it is in upper case, thenconvert it into lower case and vice versaarrow_forwardWrite a Python program in a .py file that implements a new encryption algorithm that includes the following: User enters a plaintext string Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left (as in MINDTAP exercise 4.5) Output the encrypted string. Reverse the process by having a user now enter an encrypted string and output the decrypted string.arrow_forwardWrite a java program that replace each line of a file with its reverse. For example, we have in file this data: Hello I am world! Hello world), Smart. -if you run the output is: olleH !dlrow ma I .tramS,) dlrow olleH -Of course, if you run reverse twice on the same file, you get back the original file.arrow_forward
- Write a program that reads lines of characters froma text file and writes each line as a UTF string into a binary file. Display thesizes of the text file and the binary file. Use the following command to run theprogram:java Exercise17_04 Welcome.java Welcome.utfarrow_forwardI need help fixing this Java program as shown below: import java.util.Scanner;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.PrintWriter;import java.io.IOException; public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); /* TODO: Declare any necessary variables here. */ /* TODO: Read a file name from the user and read the tsv file here. */ /* TODO: Compute student grades and exam averages, then output results to a text file here. */ }}arrow_forwardTrace the following Code and then print the output. msg db 'hello world$' newline db 10,13,'$' buffer db 10 dup mov ah,9 mov dx,offset msg int 21h ;new line mov ah,9 mov dx, offset newline int 21h ;enter a string from the keyboard lea dx,buffer mov ah,0ah int 21h ;new line mov ah,9 mov dx,offset newline int 21h ;adding the $ symbol at the end of the string mov bx,0 mov bl,buffer[1] mov buffer[bx+2],'$' mov ah,9 mov dx,offset buffer+2 int 21harrow_forward
- Objdump can disassemble programs like a.out, but not binary object files like src.o. True Falsearrow_forwardWrite a high-security program in C that reads positive integers from a file "/challenge/numbers.txt" in the same directory as the program and outputs the biggest and smallest number. Input (from numbers.txt): 100 45 12 0 42 922 2 Output: 922 0arrow_forwardWrite an address book program that stores your contacts' names and their email addresses. The names and email addresses are originally stored in a file called phonebook.in, in the format: Harry Potter t..d@hogwarts.edu Hermione Granger b..h@hogwarts.edu Ron Weasley r..b@hogwarts.edu Draco Malfoy m..s@hogwarts.edu Severus Snape h..e@hogwarts.edu Albus Dumbledore a..x@hogwarts.edu Your program should read from the file, storing the names and corresponding email addresses in a dictionary as key-value pairs. Then, the program should display a menu that lets the user enter the numbers 1 through 5, each corresponding to a different menu item: 1) look up an email address 2) add a new name and email address 3) change an email address 4) delete a name and email address 5) save address book and exit When the user enters 1, the program should prompt them for a name, and then print the corresponding email address. If there is no dictionary entry under that name, the program should print, "Sorry,…arrow_forward
- 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