You could do
return Integer.toString(Integer.parseInt(number, base1), base2);
So with your function signature, in Java:
public String convertFromBaseToBase(String str, int fromBase, int toBase) {
return Integer.toString(Integer.parseInt(str, fromBase), toBase);
}