Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help writing two classes, BitInputStream and BitOutputStream. I will provide the skeleton code for both classes. BitInputStream is supposed to be able to

I need help writing two classes, BitInputStream and BitOutputStream. I will provide the skeleton code for both classes. BitInputStream is supposed to be able to read individual bits from a file. BitOutputStream is supposed to take in a charActer, and be able to write the bits to an output file.

BitInputStream import java.io.FileInputStream;

import java.io.IOException;

public class BitInputStream {

// add additional protected variables as needed

// do not modify the public methods signatures or add public methods

protected DataInputStream d;

public BitInputStream(String filename) {

try {

d = new DataInputStream(new FileInputStream(filename));

} catch (IOException e) {

}

}

public int readBit() {

// return the next bit in the file

} public void close() {

}

} BitOutputStream import java.io.DataOutputStream;

import java.io.FileOutputStream;

import java.io.IOException;

public class BitOutputStream {

// add additional protected variables as needed

// do not modify the public methods signatures or add public methods

protected DataOutputStream d; public BitOutputStream(String filename) {

try {

d = new DataOutputStream(new FileOutputStream(filename));

} catch (IOException e) {

}

}

public void writeBit(char bit) {

// PRE: bit is a '0' or a '1'

}

public void close() {

}

}

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

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions