import java.io.*; public class Bitid8{ public static void main(String[] argumendid) throws IOException{ BitiSisendVoog bsv=new BitiSisendVoog("bitijada.dat"); while(bsv.veel()){ System.out.print((bsv.loeBitt())?"1":"0"); } bsv.close(); } static class BitiSisendVoog extends FileInputStream{ int nr=0; boolean veel=true; int malu=0; public BitiSisendVoog(String failinimi) throws IOException{ super(failinimi); loeJargmine(); } public boolean veel(){ return veel; } private void loeJargmine() throws IOException{ malu=read(); nr=0; if(malu==-1){veel=false;} } public boolean loeBitt() throws IOException{ if(!veel){throw new IOException("Bitid otsas");} boolean vastus=(malu&128)!=0; //kas seitsmes bitt on püsti malu<<=1; nr++; if(nr==8){loeJargmine();} return vastus; } public int mitmesBitt(){ return nr; } } }