Your byte array must have some encoding. The encoding cannot be ASCII if you've got negative values. Once you figure that out, you can convert a set of bytes to a String using:

byte[] bytes = {...}
String str = new String(bytes, StandardCharsets.UTF_8); // for UTF-8 encoding

There are a bunch of encodings you can use, look at the supported encodings in the Oracle javadocs.

Answer from omerkudat on Stack Overflow
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java โ€บ how to convert byte[] array to string in java
How to convert byte[] array to String in Java | mkyong.com
January 18, 2022 - In Java, we can use new String(bytes, StandardCharsets.UTF_8) to convert a byte[] to a String. // string to byte[] byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8); // byte[] to string String s =
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-program-to-convert-byte-array-to-string
Java Program to Convert Byte Array to String - GeeksforGeeks
It is as shown in the below example ... a string from the byte array // without specifying character encoding String string = new String(bytes); // Printing the string System.out.println(string); } }...
Published: July 23, 2025
Discussions

java - How to convert byte array to string and vice versa? - Stack Overflow
Not every byte array is a valid UTF-8-encoded string. ISO-8859-1 would be a better choise: here each character is encoded as a byte. 2016-04-01T06:06:49.047Z+00:00 ... This might work, but you should avoid using String constructor at all cost. 2017-06-26T17:13:02.05Z+00:00 ... to map one byte to one char (with 8859-1) and no exception handling (with nio.charset): String str = new String(bytes, java... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do you convert an "Byte array to string" text array back to normal text?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
๐ŸŒ r/javahelp
7
4
February 24, 2021
arrays - How to convert Java String into byte[]? - Stack Overflow
In your result [B@38ee9f13, the [B means byte[] and 38ee9f13 is the memory address, separated by an @. ... But this will just display as a sequence of comma-separated integers, which may or may not be what you want. ... The reason the Charset version is favoured, is that all String objects in Java ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Writing an object to S3 from a (java) string or bytestream which contains multi-glyph emoji truncates the output.
This input:

๐Ÿ‘จ๐Ÿฟ ๐Ÿ‘จ ๐Ÿ™๐Ÿผโ€โ™€๏ธ

Produces a file which I can't open because IntelliJ can't work out the encoding but Notepad++ reads it as:

๐Ÿ‘จ๐Ÿฟ๐Ÿ‘จ๐Ÿ™ If I tell Notepad++ that it is UTF-8.

More on reddit.com
๐ŸŒ r/aws
3
0
March 20, 2023
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ string-byte-array-java
String to byte array, byte array to String in Java | DigitalOcean
Technical tutorials, Q&A, events โ€” This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
๐ŸŒ
Java67
java67.com โ€บ 2015 โ€บ 05 โ€บ how-to-convert-byte-array-to-string-in-java-example.html
How to Convert Byte array to String in Java with Example | Java67
The rest of the example is pretty straightforward as we already have a byte array and we are just using an overloaded String constructor which also accepts encoding. For a more complex example, where we read content from an XML file, see this tutorial. There are also printable and non-printable characters in ASCII, which is handled differently by different character encoding. import java.io.UnsupportedEncodingException; public class ByteArrayToStringDemo { public static void main(String args[]) throws UnsupportedEncodingException { byte[] random = new byte[] { 67, 65, 70, 69, 66, 65, 66, 69, -
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2014 โ€บ 08 โ€บ 2-examples-to-convert-byte-array-to-String-in-Java.html
2 Examples to Convert Byte[] Array to String in Java
In this article, we will learn how to convert byte[] to String in Java both by using JDK API and with the help of Guava and Apache commons. There are multiple ways to change byte array to String in Java, you can either use methods from JDK, or you can use open-source complementary APIs like Apache commons and Google Guava.
๐ŸŒ
Java Code Geeks
examples.javacodegeeks.com โ€บ home โ€บ java development โ€บ core java
Java Convert Byte[] array to String Example - Java Code Geeks
April 14, 2019 - It includes test methods to convert ... public class ByteArrayToStringTest { private static final String MARY = "Mary"; private byte[] TEST_BYTES_ARR = new byte[] { 77, 97, 114, 121 }; @Test public void test_default() { String ...
Find elsewhere
๐ŸŒ
Attacomsian
attacomsian.com โ€บ blog โ€บ java-convert-byte-array-to-string
How to convert a byte array to a string in Java
October 29, 2022 - If the character encoding is different, you can specify it by passing another argument to new String() as shown below: String str = new String(bytes, StandardCharsets.UTF_8); Since Java 8, we have Base64 class available that provides static ...
๐ŸŒ
Reddit
reddit.com โ€บ r/javahelp โ€บ how do you convert an "byte array to string" text array back to normal text?
r/javahelp on Reddit: How do you convert an "Byte array to string" text array back to normal text?
February 24, 2021 -

I got a string called abc, I got the bytes of abc and put them into the byte array named b, then i created a string which converts byte array b to string via Arrays.toString(b). This results in [97, 98, 99, 100, 101, 102, 103, 104, 105, 103, 104, 116].

How would you reverse this? (it's a seperate function).

Top answer
1 of 3
4
Try new String(b); This will convert it back to a regular string.
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java-program-to-convert-byte-array-to-string
Java Program to convert byte[] array to String
// byte array byte[] arr = new byte[] {78, 79, 33}; Now take a String and include the array in it. String str = new String(arr); Let us see the complete example to convert byte array to String.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ convert byte array to string in java
Convert Byte Array to String in Java - Scaler Topics
May 4, 2023 - We will be discussing the two most commonly used techniques to convert byte array to string. They are as follows: String class constructor. UTF-8 Encoding. ... The first technique that we are going to discuss is using a string class constructor. It is one of the simplest techniques. In this method we need to pass the byte[] as an argument to the string class constructor. Following is an example that displays the use of a string class constructor.
๐ŸŒ
Crunchify
crunchify.com โ€บ java j2ee tutorials โ€บ in java how to convert byte[] array to string and string to byte[]?
In Java How to convert Byte[] Array To String and String to Byte[]? โ€ข Crunchify
December 28, 2025 - The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array. ... Modern, Secure & Fast Managed WordPress Hosting. Check it out. Learn more ยท Singleton Pattern Java Caching LinkedList Iterator Java Abstract Java Static Intro Java Interface Github OAuth Sorting Algorithm Plugins we Use Top Backup Plugins Domain Authority Tips Interlinking Tips Setup Forum
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ java โ€บ how to convert byte array to string in java
How to Convert Byte Array to String in Java | Delft Stack
February 26, 2025 - This method provides more control over the character encoding and is suitable for larger byte arrays. import java.io.ByteArrayInputStream; import java.io.InputStreamReader; import java.io.BufferedReader; byte[] byteArray = {72, 101, 108, 108, 111}; ...
๐ŸŒ
Codeblogmoney
codeblogmoney.com โ€บ byte-array-to-string-in-java
Byte Array to String in Java - Code Blog Money
June 9, 2020 - Byte Array to String code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public class ByteArrayToString { public static void main(String[] args) { byte[] byteArray= {67,111,100,101,32, 66,108,111,103,32, 77,111,110,101,121}; //Convert byte[] to String String ...
๐ŸŒ
Java Code Geeks
javacodegeeks.com โ€บ home โ€บ core java
2 Examples to Convert Byte[] array to String in Java
September 3, 2014 - As you can see that Java API, particularly java.lang.String class provides methods and constructor that takes a byte[] and returns a String (or vice versa), but by default they rely on platformโ€™s character encoding, which may not be correct, if byte array is created from XML files, HTTP request data or from network protocols.
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ java array โ€บ convert byte[] to string and vice-versa
Convert byte[] Array to String in Java - HowToDoInJava
December 15, 2022 - Learn to convert byte[] to String and String to byte[] in java โ€“ with examples. Conversion between byte array and string may be used in many cases including IO operations, generate secure hashes etc.
๐ŸŒ
Techie Delight
techiedelight.com โ€บ home โ€บ java โ€บ convert a byte array to a string in java
Convert a byte array to a String in Java | Techie Delight
July 7, 2026 - This post will discuss how to convert a byte array to string in Java.. We know that a string store textual data in Java, and `byte[]` stores binary data, so we should avoid conversion between them.
๐ŸŒ
Medium
medium.com โ€บ @ujjawalr โ€บ convert-byte-to-string-in-5-ways-in-java-28271e01e6b8
Convert byte[] to String in 5 ways in java | by Ujjawal Rohra | Medium
February 12, 2023 - Example, byte[] bytes = {72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100}; String str = new String(bytes); System.out.println(str); // Hello World ยท This method will only work if the contents of byte array represent a string underneath.