public static byte[] toByteSequence(String data) throws Exception{
    
    /* Counter for making sequence. */
    int j=-1;
    
    /* Size of the byte array. */
    int byteArrSize = data.length()/8;
    
    /* Checks if the byte array size is adequate. */
    if (data.length()%8 != 0)
      byteArrSize++;
    
    /* Byte array for output. */
    byte[] byteSeq = new byte[byteArrSize];
    
    /* Converts the encoded file to byte code. */
    for(int i=0;i< data.length();i++){
      
      if (i%8 == 0){
        j++;
        byteSeq[j] = 0x00;
      }
      
      byte tmp;
      
      if (data.charAt(i) == '1'){
        tmp = 0x01;
      } else if (data.charAt(i) == '0') {
        tmp = 0x00;
      } else
        throw new Exception ("error in format");
      byteSeq[j] = (byte) (tmp | ( byteSeq[j] << 1));
    }
    
    return byteSeq;
  }