0

I have created a file called"output.txt" using this code snippet.

public static void main(String args[]) throws IOException{
    BitSet bitset = new BitSet();
    for(int i = 0; i<100; i++){
        if(i%2 == 0){
            bitset.set(i, false);
        }else{
            bitset.set(i, true);
        }
    }

    FileOutputStream fout = new FileOutputStream("output.txt");
    byte[] bs = bitset.toByteArray();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(bs);
    baos.writeTo(fout);
}

Now how do I read "output.txt" file and get my byte[] bs back? Can anyone give me code for that? I am having trouble writing ByteArrayInputStream code.

Thanks

theprogrammer
  • 1,698
  • 7
  • 28
  • 48

0 Answers0