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
🌐
Baeldung
baeldung.com › home › java › java string › convert string to byte array and reverse in java
Convert String to Byte Array and Reverse in Java | Baeldung
March 17, 2024 - Similar to encoding, this process requires a Charset. However, we can’t just use any charset for decoding a byte array. In particular, we should use the charset that encoded the String into the byte array. We can also convert a byte array to a String in many ways.
Discussions

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
Convert byte array to string

If you're trying to create a String from a C-style char* string, the string has to be null-terminated. If the final element of byteArray is not 0, then the program does not know how long your string is and will overrun into whatever follows it in memory.

Sometimes what follows may be a 0 and the string terminates correctly, other times it will be followed by random data that is then appended to the string.

You haven't told the String constructor how long byteArray is, so how would it know how long to make strData? The answer is that it copies data until it reaches that terminating null character.

 

edit

Unfortunately the String methods which accept a length argument are protected. Try something like this, where you iterate through each element and append it individually:

String strData;
for (char c : byteArray) strData += c;
More on reddit.com
🌐 r/arduino
21
0
September 23, 2016
python - How to convert a byte array to string? - Stack Overflow
I just finished creating a huffman compression algorithm . I converted my compressed text from a string to a byte array with bytearray(). Im attempting to decompress my huffman algorithm. My only c... More on stackoverflow.com
🌐 stackoverflow.com
c# - How to convert byte array to string - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. ... Closed 12 years ago. I created a byte array with two strings. How do I convert a byte array to string? More on stackoverflow.com
🌐 stackoverflow.com
🌐
Online String Tools
onlinestringtools.com › convert-bytes-to-string
Convert Bytes to a String – Online String Tools
Free online bytes to a string converter. Just load your byte array in the input area and it will automatically get converted to a string. There are no intrusive ads, popups or nonsense, just a neat converter. Load bytes – get a string.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › visual-basic › programming-guide › language-features › strings › how-to-convert-an-array-of-bytes-into-a-string
How to: Convert an Array of Bytes into a String - Visual Basic | Microsoft Learn
September 15, 2021 - Private Function UnicodeBytesToString( ByVal bytes() As Byte) As String Return System.Text.Encoding.Unicode.GetString(bytes) End Function · You can choose from several encoding options to convert a byte array into a string:
🌐
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.
🌐
C# Corner
c-sharpcorner.com › article › how-to-convert-a-byte-array-to-a-string
Convert Byte Array To String In C#
February 9, 2023 - The BitConverter class has a static overloaded GetBytes method that takes an integer, double, or other base type value and converts that to an array of bytes. The BitConverter class also has other static methods to reverse this conversion. Some of these methods are ToDouble, ToChart, ToBoolean, ToInt16, and ToSingle. The following code snippet converts a byte array into a string.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-convert-byte-array-to-string
Java Program to Convert Byte Array to String - GeeksforGeeks
We can convert the byte array to String for the ASCII character set without even specifying the character encoding. The idea is to pass the byte[] to the string.
Published   July 23, 2025
Find elsewhere
🌐
Javatpoint
javatpoint.com › how-to-convert-byte-array-to-string-in-java
How to convert byte array to String in Java?
How to Convert byte Array to String in Java with oops, string, exceptions, multithreading, collections, jdbc, rmi, fundamentals, programs, swing, javafx, io streams, networking, sockets, classes, objects etc,
🌐
Code Beautify
codebeautify.org › byte-to-string
Best Byte to String Online Converter
Byte to String Converter helps to convert Byte buffer to String, which help users to decode bytes into readable texts with free and easy to use tool. Converting Byte Array to String helps you to view and read your Byte data as String.
🌐
Tooloogle
tooloogle.com › home › tools › byte array to string converter - convert bytes to text online
Byte Array to String Converter - Convert Bytes to Text Online
... The Tooloogle Byte Array to String Converter takes a list of byte values — space-separated or comma-separated — and decodes them into a readable UTF-8 string in your browser.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.bitconverter.tostring
BitConverter.ToString Method (System) | Microsoft Learn
Converts the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation.
🌐
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.
🌐
Reddit
reddit.com › r/arduino › convert byte array to string
r/arduino on Reddit: Convert byte array to string
September 23, 2016 -

I am trying to convert byte array to string. It is working fine for some cases but doesnt work with others.

String strData=String ((char*)byteArray);

strData has an extra char at the end. But sometimes it doesnt has that char and working perfectly fine. There is no extra char in the byte array. I double Checked.

Any help would be appreciated. Thanks

Edit: I think there is a problem with my program design. I need to create a lookup table. I need to read values from addresses against the strings. The Strings will come from c# application in the form of byte array. I am trying to convert byte array to String.

🌐
DigitalOcean
digitalocean.com › community › tutorials › string-byte-array-java
String to byte array, byte array to String in Java | DigitalOcean
August 3, 2022 - That’s why the output is the same for both the byte array to string conversion. String also has a constructor where we can provide byte array and Charset as an argument. So below code can also be used to convert byte array to String in Java.
🌐
ToolsOverflow
toolsoverflow.com › string › bytes-to-string
Bytes to String Converter
December 7, 2024 - This Bytes to String tool is a simple web utility that converts a series of bytes (which are just numbers) into a readable text or string.
🌐
Baeldung
baeldung.com › home › scala strings › convert byte array to string in scala
Convert Byte Array to String in Scala | Baeldung on Scala
March 19, 2025 - A Byte Array is a type in Scala that represents a series of bytes. We can define one in Scala by creating an Array of type Byte and listing out the literal values of the bytes: ... Naturally, if we want to get the string value from something in Scala, we assume we can call toString():