A very basic way to do this would be :
String replaceCharsByNumbers(String stringToChange) {
return stringToChange
.replace('a', '2')
.replace('b', '2')
.replace('c', '2')
.replace('d', '3')
.replace('e', '3')
.replace('f', '3')
.replace('g', '4')
.replace('h', '4')
.replace('i', '4')
.replace('j', '5')
.replace('k', '5')
.replace('l', '5')
.replace('m', '6')
.replace('n', '6')
.replace('o', '6')
.replace('p', '7')
.replace('q', '7')
.replace('r', '7')
.replace('s', '7')
.replace('t', '8')
.replace('u', '8')
.replace('v', '8')
.replace('w', '9')
.replace('x', '9')
.replace('y', '9')
.replace('z', '9');
}