for a decimal x (base 10) you can use respectively for binary, octal, hex conversion
Integer.toString(x, 2),
Integer.toString(x, 8)
Integer.toString(x, 16).
then to convert it back to decimal, respectively from binary, octal, hex conversion
Integer.valueOf(binary_value, 2)
Integer.valueOf(octal_value, 8)
Integer.valueOf(hex_value, 16)
in your code, change the following:
output = Integer.toString(input, 16) //replace 16 for hex, 8 for octal, 2 for binary