Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!