This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I wrote a program that generated a 20 byte SHA-1 hash value. The values are in a byte array and I am trying to print them out as hexadecimal string. I am having problems printing out negative values. e.g. byte b = (byte)0xff; System.out.println( Integer.toHexString(b) ); produces fffffffd ?? Shouldn't I get back ff ? Thanks Pho
I believe the below from the api states exactly what is happening toHexString Creates a string representation of the integer argument as an unsigned integer in base 16. The unsigned integer value is the argument plus 2^32 if the argument is negative; otherwise, it is equal to the argument. Hope that helps, Tom ------------------