Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/01/2012, 23:47
juliochinchilla
 
Fecha de Ingreso: septiembre-2011
Mensajes: 12
Antigüedad: 12 años, 7 meses
Puntos: 0
Respuesta: String a Byte Hexadecimal

tengo esta función y asi como tu dices no funciona, me manda esta excepción
Cita:
Exception in thread "main" java.lang.NumberFormatException: For input string: "f"
Cita:
public byte [] ochoBits (int b) {
byte [] ocho = null;
String c = Integer.toHexString(b);
System.out.println(c.length());
if (c.length() == 4) {
ocho [0] = Byte.parseByte(c.substring(0, 1));
ocho [1] = Byte.parseByte(c.substring(2, 3));
} else if (c.length() == 3) {
System.out.print(c+"tres");
} else if (c.length() == 2) {
System.out.print(c+"dos");
} else if (c.length() == 1) {
System.out.print(c+"uno");
}
return ocho;
}