public void setEndian(int endian) {
      if(this.endian==BIG_ENDIAN && endian==LITTLE_ENDIAN) {
         bitIndex=0;
         byteIndex++;
      }
      else if(this.endian==LITTLE_ENDIAN && endian==BIG_ENDIAN) {
         bitIndex=7;
         byteIndex++;
      }
      this.endian=endian;
   }