i got that when executing the code below: (the problem seems to be with the insert method but can't really figure it out) (i would appreciate if you point out the solution)**
public void writeBit(char bit) throws IOException{
b.insert(0, bit);
if(b.length()==8){
a.write(Integer.parseInt(b.toString()));
b.setLength(0);
}
}