convert « hexadecimal « Java Data Type Q&A

1. Converting A String To Hexadecimal In Java

I am trying to convert a string like "testing123" into hexadecimal form in java. I am currently using BlueJ. And to convert it back, is it the same thing except backward? ...

2. CPP to Java conversion

Here's my scenario. I have an application written in C++ but not the complete source but the "meat" of it is there. I also have a compiled exe of ...

3. Java String conversion to hex

I am working on a tcp/ip socket listener which listens on port 80 for data that arrives from remote hosts. Now these incoming data are in unreadable format and so i ...

4. Convert hexadecimal notation into latitudinal hours and minutes


  • 0x12E7 represents 48°39'
  • 0x3026 represents 123°26'
What is the most efficient way to convert the representation of those latitudes into two variables:
  • hours
  • minutes
Where the first example would be:
  • hours = 48
  • minutes = 39
And the second ...

5. Best way to convert hex string to string in Java?

I am returned a string in the form of "0x52 0x01 0x23 0x01 0x00 0x13 0xa2 0x00 0x40 0x53 0x2b 0xad 0x48 0x5f 0x30 0x30 0x31 0x33 0x41 0x32 0x30 0x30 ...

6. Java convert a HEX String to a BigInt

Hi am trying to convert a hex string such as String hexStr = "1b0ee1e3"; to a bigInt, ideally i'd like to convert hexStr to a bigint in its decimal form, I can convert ...

7. How to convert a hexadecimal string to long in java?

I want to convert a hex string to long in java. I have tried with general conversion.

String s = "4d0d08ada45f9dde1e99cad9";
long l = Long.valueOf(s).longValue();
String ls = Long.toString(l);
But I am getting this error ...

8. Java convert hex to time

I really have no idea where to start on this, I have done some research but been unable to find anything. I know I have to use the date class but ...

9. Function for converting octal to hexadecimal in Java

Is there a function I can use to convert octal to hexadecimal in java?

10. Java - parse and unsigned hex string into a signed long

I have a bunch of hex strings, one of them, for example is:

which is the hex value of "-3333702275990511909". This is the same hex you get if you ...

11. Convert UUID to hex string and vice versa

A UUID in the form of "b2f0da40ec2c11e00000242d50cf1fbf" has been transformed (see the following code segment) into a hex string as 6232663064613430656332633131653030303030323432643530636631666266. I want to code a reverse routine and get it ...

12. Error in converting to hex and then back to normal string

I am using the following code for a my sampled 3DES encryption i am using....

package Algorithms;

import java.util.Arrays;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;

public class MyDES {

13. How to convert Hex into UpperCase Alphabets?

All, I created a sample key generator which generates UUIDs (with lots of hex for the output like this): import java.util.UUID; public class KeyGenerator { public UUID getKeysFromInputSeeds(long startTimeStamp, Number sequenceId) throws Exception { String concatenatedSeeds = Long.toString(startTimeStamp) + sequenceId.toString(); byte[] inputSeeds = concatenatedSeeds.getBytes(); return getKeyFromBytes(inputSeeds); } private UUID getKeyFromBytes(byte[] seed) { return UUID.nameUUIDFromBytes(seed); } } The main app: public class ...

14. Hex Conversion

I have an idea. I want to store color information in a short instead of an int. Currently color information is stored in an int like so: 0x00RRGGBB I want to use this format: 0x0RGB Is there a formula or bit shift I can use to do the conversion back and forth? I realize I will have less colors to work ...

15. Hexadecimal Conversion

This is probably way to easy, but does anyone have any suggestions as to how I can easily convert an integer input into hexadecimal. This assignment calls for the user to be able to enter a number from 0-100,000, and that number be converted to hex. There has to be an easier way of converting than a huge branching if...else if..etc. ...

16. Hex to jpeg conversion

Why are you converting a byte[] into a StringBuffer/String? Seems odd to me. Anyway, one way to reverse a process is to reverse each step. For example, how can you convert "A0" back to a byte? Take a look at the methods of Integer. In the final step, to convert a byte[] to an Image, take a look at class javax.imageio.ImageIO, ...

17. Logic error (regarding hexadecimal conversion)

Hello everyone. This is the second time I've came here with a specific question. Everyone was great last time - I learned so much in the process. This time, my question is quite simple. Basically, I am inputting an integer. The integer needs to be transformed into a "hexcode." In this example, 525 is input. It needs to be turned into ...

18. How to convert Hex into Alphabets and Obfuscate?

All, I created a sample key generator which generates UUIDs (with lots of hex for the output like this): import java.util.UUID; public class KeyGenerator { public static UUID getKeyFromInputSeeds(long startTimeStamp, Number sequenceId, String oneTypeOfString, String aDifferentTypeOfString) throws Exception { String concatenatedSeeds = Long.toString(startTimeStamp) + sequenceId.toString() + oneTypeOfString + aDifferentTypeOfString; byte[] inputSeeds = concatenatedSeeds.getBytes(); return getKeyFromBytes(inputSeeds); } private static UUID getKeyFromBytes(byte[] seed) ...

19. Hex to long conversion

20. How to convert arabic into UCS hexadecimal code?

I have a code like this- public class ArabToHex { public static String stringToHex(String pData) { StringBuffer encodedData = new StringBuffer(); StringBuffer sBuff = new StringBuffer(pData); for (int i = 0; i < sBuff.length(); i++) { char ch = sBuff.charAt(i); int chVal = (int)ch; // if this is a special character (ie. > 8 bits), encode it if (chVal > Byte.MAX_VALUE) ...

21. How to convert a String into an Hexadecimal ?

Hi! I have a String which represents a hexadecimal number (e.g. "5FA2"). Ideally, I would like to convert this String into an int (e.g. 0x5FA2), is there a quick way to do this ? I can't use the method "Integer.parseInt()" since my String represents an hexadecimal and not a decimal. Thanks in advance!

22. String to Hex Conversion

Hi, I have here the code and i want to convert the inputted list version by the user. The inputted list version , once the URL was generated. The List Version must generate, for 11 as inputted list version in textListVersion it must generate %00%00%0B. PLease help me to fix this problem. thanks i advance. :D __________________________________________________ _____________ private void sendRefresh(int ...

23. converting hex to dec -

Hi I am getting some hex data from a processor, and need it converted to decimal. I am stripping 2 chars from the input and parsing the rest into a 'line' So in my 'line' I have 3ff or similar. I need this converted to decimal... I seem to have hit a wall.. All I can find is dec to hex ...

24. Need help modifying code for hex conversion

Hi everyone. I'm new to Java and look forward to learning alot from here. Currently I have a little problem with my code. I need to modify my existing java code which converts a base 10 value to base 10 and below. I need help modifying my code to allow for hex conversion also. My instructions are: Modify your program to ...

25. Returning a variable after converting it into hexadecimal

Sorry must be clearer. I'm pretty sure that I am not returning the name variable from the for loop correctly so that the callbackhandler can pick up the hexadecimal string (which is what I am attempting to get for the rest of my code). Do I need to rename the new hexed string to something like hexname? The original cookie code ...

26. Converting a string to hex

27. How to convert string to long hexadecimal number

cotton thanks for your reply, but I dont want only to print, I mean when I checked that value should be like : 0xc0a80000 , but not my intention is to print that. If I do want to print like that , I can write like : System.out.println("0xc0a80000"); I think you understood my question.

28. Hex conversion problem... Please help

Hi all, I need to convert a hex character representing a UTF-16 character to a hex string representing a UTF-8 character i.e String input ="0x0630"; //ARABIC LETTER THAL (UTF-16) I want the output to be a hex representation of the same charcter in UTF-8. Does anyone know the java code to do this?

29. Converting Long String of numbers to the Hex.

Hi Everyone, Here is my challenge. I am given a very large number in a String. I am also given the maximum number of bits this number can occupy. However, this number probably will not fit into a standard Data Type such as long, int, or double. I also need to send this number to a piece of hardware in a ...

30. HEX conversion methods?

hey thanx its working correctly i am getting HIOX as my result...thanks! but there is one problem wjen i give the input as D07C580E it gives me Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"D0" Radix:16 at java.lang.Byte.parseByte( at Test.main( this exception why is it so????? when it is working for 48494f58 as input why not for D07C580E?????? Edited ...

31. Convert UTF-16 string to UTF-8 or Hexadecimal

32. Converting hexadecimal to unique intger

33. HEX to Signed Number Conversion

Hi i was trying to read a binary database where in -1 is represented as FFFF , in case of 2 bytes and FFFFFFFF in case of 4 bytes.The Field will have some times positive values also.Can anybody suggest me a method/Algo to decode it back to -1 or corresponding integer value. Thanks in Advance.

34. Conversion of Hex to Base 64

Take your Hex (base16) and use the Base64Encoder. It does not matter what base your source is, as that is independent of the operation you are performing. The encoder will change the given data based on it's formula to produce a result. The decoder will take that result and produce the original content (weather it was base64, base10, base16). Short: Use ...

35. Hex string conversion to negative long