public static void writeBcdNumber(OutputStream os,String number) throws IOException {
  int bcd=0x00;
  int n=0;
  for (int i=0; i < number.length(); i++) {
switch (number.charAt(i)) {
case '0':
      bcd|=0x00;
    break;
case '1':
  bcd|=0x10;
break;
case '2':
bcd|=0x20;
break;
case '3':
bcd|=0x30;
break;
case '4':
bcd|=0x40;
break;
case '5':
bcd|=0x50;
break;
case '6':
bcd|=0x60;
break;
case '7':
bcd|=0x70;
break;
case '8':
bcd|=0x80;
break;
case '9':
bcd|=0x90;
break;
case '*':
bcd|=0xA0;
break;
case '#':
bcd|=0xB0;
break;
case 'a':
bcd|=0xC0;
break;
case 'b':
bcd|=0xE0;
break;
}
n++;
if (n == 2) {
os.write(bcd);
n=0;
bcd=0x00;
}
 else {
bcd>>=4;
}
}
if (n == 1) {
bcd|=0xF0;
os.write(bcd);
}
}

public static void writeBcdNumber ( OutputStream os , String number ) throws IOException { int bcd = 0x00 ; int n = 0 ; for ( int i = 0 ; i < number . length ( ) ; i ++ ) { switch ( number . charAt ( i ) ) { case '0' : bcd |= 0x00 ; break ; case '1' : bcd |= 0x10 ; break ; case '2' : bcd |= 0x20 ; break ; case '3' : bcd |= 0x30 ; break ; case '4' : bcd |= 0x40 ; break ; case '5' : bcd |= 0x50 ; break ; case '6' : bcd |= 0x60 ; break ; case '7' : bcd |= 0x70 ; break ; case '8' : bcd |= 0x80 ; break ; case '9' : bcd |= 0x90 ; break ; case '*' : bcd |= 0xA0 ; break ; case '#' : bcd |= 0xB0 ; break ; case 'a' : bcd |= 0xC0 ; break ; case 'b' : bcd |= 0xE0 ; break ; } n ++ ; if ( n == 2 ) { os . write ( bcd ) ; n = 0 ; bcd = 0x00 ; } else { bcd >>= 4 ; } } if ( n == 1 ) { bcd |= 0xF0 ; os . write ( bcd ) ; } }
writes the given phonenumber to the stream ( bcd coded )
