Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do the above problem using this codes: Follow the same functions do not buffered it import java.io.*; /** * This program reads UTF-8 encoded strings

image text in transcribed

Do the above problem using this codes: Follow the same functions do not buffered it

import java.io.*;

/** * This program reads UTF-8 encoded strings from a binary file. */

public class ReadUTF { public static void main(String[] args) throws IOException { String name; boolean endOfFile = false; FileInputStream fstream = new FileInputStream("UTFnames.dat"); DataInputStream inputFile = new DataInputStream(fstream); System.out.println("Reading the names from the file:"); while (!endOfFile) { try { name = inputFile.readUTF(); System.out.print(name + " "); } catch (EOFException e) { endOfFile = true; } }

System.out.println(" Done."); inputFile.close(); } }

import java.io.*;

/** * This program opens a binary file, then reads and displays * the contents. */

public class ReadBinaryFile { public static void main(String[] args) throws IOException { int number; // To hold a number boolean endOfFile = false; // End of file flag // Open Numbers.dat as a binary file. FileInputStream fstream =new FileInputStream("Numbers.dat"); DataInputStream inputFile =new DataInputStream(fstream); System.out.println("Reading numbers from the file:"); // Read data from the file. while (!endOfFile) { try { number = inputFile.readInt(); System.out.print(number + " "); } catch (EOFException e) { endOfFile = true; } }

// Close the file. inputFile.close(); System.out.println(" Done."); } }

Develop a java app named WriteNumbersinBinaryFile.java for writing the first n natural numbers in a binary file. On the other hand, develop a java app named ReadNumbersFromBinaryFile.java for reading all integer numbers in a binary file as well as getting the sum of all numbers in the binary file. Concepts in practice: Binary Files Processing with Java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

How should a firm go about constructing a product attribute map?

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago