System.out.println(new String(new byte[]{ (byte)0x63 }, "US-ASCII"));

Note especially that converting bytes to Strings always involves an encoding. If you do not specify it, you'll be using the platform default encoding, which means the code can break when running in different environments.

Answer from Michael Borgwardt 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 - The correct way to convert byte[] to string is new String(bytes, StandardCharsets.UTF_8). ... package com.mkyong.string; import java.nio.charset.StandardCharsets; public class ConvertBytesToString2 { public static void main(String[] args) { ...
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
How To Convert A String To Byte()?
In Java, the String class has a getBytes() method, which simply returns an array of bytes using the default platform encoding. Perhaps I’m blind, but I can’t seem to find any equivalent built-in way to do this in Xojo. … More on forum.xojo.com
🌐 forum.xojo.com
0
0
October 14, 2013
converting large byte array back to string
If you need it as String, why even have a byte array in the first place? Please, go into details of your use case and your reasoning for the byte array. This would probably help us. You could use a Scanner over the file and use nextByte with the delimiter set right to read in the values and directly throw them in the byte array. More on reddit.com
🌐 r/javahelp
12
2
August 21, 2025
java - Convert string to byte array in frida js script - Reverse Engineering Stack Exchange
I am having an issue with a JavaScript script to be executed in Frida. In this case, I am intercepting an input from a function where I receive an array of bytes. I need to convert this array to a ... More on reverseengineering.stackexchange.com
🌐 reverseengineering.stackexchange.com
March 6, 2024
🌐
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 ... args) throws IOException { // Getting bytes from the custom input string // using getBytes() method and // storing it in a byte array byte[] bytes = "Geeksforgeeks".getBytes(); ...
Published   July 23, 2025
🌐
Coderanch
coderanch.com › t › 396604 › java › Convert-byte-string
Convert byte to string (Beginning Java forum at Coderanch)
I have been able to get it to work using the String.valueOf, but the resulting string contains the ASCII representation of the character. I have tried all combinations of converting the in[0] to a string variable z and can not get any of them to compile. Is there a simple way to do this? ... I got this to work by using the following code; The byte (in[]) is the character rectived.
🌐
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.
🌐
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.
🌐
Oracle
docs.oracle.com › javase › tutorial › i18n › text › string.html
Byte Encodings and Strings (The Java™ Tutorials > Internationalization > Working with Text)
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases. See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases. If a byte array contains non-Unicode text, you can convert the text to Unicode with one of the String constructor methods.
Find elsewhere
🌐
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.
🌐
W3Schools
w3schools.com › java › ref_string_getbytes.asp
Java String getBytes() Method
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A ... The getBytes() method converts a string into an array of bytes.
🌐
Xojo Programming Forum
forum.xojo.com › general
How To Convert A String To Byte()? - General - Xojo Programming Forum
October 14, 2013 - In Java, the String class has a getBytes() method, which simply returns an array of bytes using the default platform encoding. Perhaps I’m blind, but I can’t seem to find any equivalent built-in way to do this in Xojo. …
🌐
Tutorialspoint
tutorialspoint.com › java › lang › byte_tostring.htm
Java - Byte toString() Method
Then we're getting string representation of byte variables using toString() method and then result is printed. package com.tutorialspoint; public class ByteDemo { public static void main(String[] args) { // create 2 Byte objects b1, b2 Byte ...
🌐
Edureka Community
edureka.co › home › community › categories › java › how to convert byte array to string and string to...
How to convert byte array to String and STring to byte array | Edureka Community
May 14, 2018 - How to convert byte array to String and STring to... how do I turn a double in an array from 1000 to infinity Jul 9, 2024 · I have created a code in java for a flower shop and now my IDE is showing all the inputs are in red showing there is an error Jul 6, 2024
🌐
Coderanch
coderanch.com › t › 394630 › java › Convert-String-Array-Byte-Array
Convert String Array to Byte Array (Beginning Java forum at Coderanch)
October 21, 2003 - I have a string array that I converted to the data to 4 hex strings. I placed the hex strings into each location of the string array. For example; String [] hex_Str; hex_Str[0] = Integer.toHexString(127); hex_Str[1] = Integer.toHexString(0); hex_Str[2] = Integer.toHexString(0); hex_Str[3] = Integer.toHexString(1); and return hex_Str I have another method that takes the string array and wishes to place it into a byte array.
🌐
Online String Tools
onlinestringtools.com › convert-string-to-bytes
Convert a String to Bytes – Online String Tools
Instant Copy-to-clipboardCopy the string to clipboard with a single click. ... If a byte is less than 0xf, make it 0x0f. ... Select this option to add a whitespace char after each byte. This browser-based program converts a string to a byte array. The string is split into individual characters and then for each character, the program finds its byte representation, and prints it in the output area in the hexadecimal base.
🌐
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 - Convert byte[] to String in 5 ways in java In this article, we will explore different ways to convert a byte array(byte[]) to a string in java with example programs. 1. Using String Constructor Java …
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-a-string-value-to-byte-value-in-java-with-examples
How to Convert a String value to Byte value in Java with Examples - GeeksforGeeks
July 12, 2025 - // Java Program to convert string to byte class GFG { // Function to convert String to Byte public static byte convertStringToByte(String str) { // Convert string to byte // using parseByte() method return Byte.parseByte(str); } // Driver code ...
🌐
Reddit
reddit.com › r/javahelp › converting large byte array back to string
r/javahelp on Reddit: converting large byte array back to string
August 21, 2025 -

So normally you can create a byte array as a variable something like

byte[] bytes = {69, 121, 101, ...};

but I have a huge one that blows up method/class file if I try this and wont compile. I've put it in a text file and trying to read it in, but now its coming as a string literal such as "69, 121, 101, ..."

if i try to use a readAllBytes method, its basically converting the above string to bytes which is now not matching and looks totally different like 49, 43, 101, .... so now its a byte array of a string-ified byte array if that makes sense.

i've managed to get it back to a byte array and then string, but it seems to be a janky way and wondering if theres a more proper way.

currently i'm

  • reading the whole string into memory

  • using string.split(",")

  • converting string value to int

  • converting int to byte

  • add to byte array

  • new String(myByteArray)

this works, but is it really the only way to do this?

🌐
Stack Exchange
reverseengineering.stackexchange.com › questions › 32790 › convert-string-to-byte-array-in-frida-js-script
java - Convert string to byte array in frida js script - Reverse Engineering Stack Exchange
March 6, 2024 - I managed to make the first step work correctly, which is converting the array of bytes into a string and modifying the string. However, the problem arises when I try to convert the string back into an array of bytes; it throws an error. I tried using the Java native function getBytes(), but it gives the error below:
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_convert_java_string_into_byte
How to convert Java String into byte[]?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
DataCamp
datacamp.com › tutorial › string-to-bytes-conversion
How to Convert String to Bytes in Python | DataCamp
June 5, 2024 - Strings represent human-readable text and are one of the most basic and important data types in computer programming. However, each character in a text string is represented by one or more bytes of binary data. Applications such as input and output operations and data transmission require strings to be converted to bytes using a specific encoding.