How to convert a java string into byte array

0 votes
How can I make a string to byte array? Please help!
Jun 21, 2018 in Java by scarlett
• 1,280 points
43 views

1 answer to this question.

0 votes

You can probably use ByteBuffer: 

byte[] byte = ByteBuffer.allocate(4).putInt(1695609641).array();

for (byte a : byte) {
   System.out.format("0x%x ", a);
}
answered Jun 21, 2018 by Perry
• 17,010 points

Related Questions In Java

0 votes
1 answer

How to convert a string representation of a hex dump to a byte array using Java?

public static byte[] hexStringToByteArray(String s) { ...READ MORE

answered Sep 26, 2018 in Java by sharth
• 3,320 points
135 views
0 votes
1 answer

How can I convert byte array into hex string in Java?

private final static char[] hexarr = "0123456789ABCDEF".toCharArray(); public ...READ MORE

answered May 24, 2018 in Java by sharth
• 3,320 points
321 views
0 votes
1 answer

How to convert a JSON String into Object in Java?

We can easily convert a JSON String ...READ MORE

answered Jun 8, 2018 in Java by parth295
• 4,600 points
253 views
0 votes
1 answer

How to convert a byte into Hexadecimal in Java?

byte[] bytes = {-1, 0, 1, 2, ...READ MORE

answered Aug 21, 2018 in Java by parth295
• 4,600 points
32 views
0 votes
1 answer

How can we convert Strings to and from UTF8 byte arrays?

To convert STring to byte[]: String s = ...READ MORE

answered Jun 21, 2018 in Java by Akrati
• 3,150 points
26 views
0 votes
1 answer

How can two strings be concatenated in java?

You can concatenate Strings using the + operator: System.out.println("Your number ...READ MORE

answered Jun 6, 2018 in Java by Daisy
• 8,040 points
17 views
0 votes
2 answers

How an object array can be converted to string array in java?

System.arraycopy is the most efficient way, but ...READ MORE

answered Aug 8, 2018 in Java by Sushmita
• 6,850 points
86 views
0 votes
1 answer

Why is char[] preferred over a string?

Strings are immutable. That means once you've ...READ MORE

answered Jun 14, 2018 in Java by scarlett
• 1,280 points
23 views
0 votes
2 answers

How can I do url string decoding in java

We can use URLDecoder: URLDecoder.decode( url, "UTF-8" ); READ MORE

answered Dec 7, 2018 in Java by Sushmita
• 6,850 points
23 views
0 votes
1 answer

What is the difference between getAttribute() and getParameter() in java?

getParameter() - getParameter will return the value of ...READ MORE

answered Jun 29, 2018 in Java by Perry
• 17,010 points
458 views