Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert com.google.protobuf.ByteString to String

Tags:

java

I have a Bytestring that I need to display to the console in java.

The Bytestring is of type com.google.protobuf.ByteString,

I am using:

System.out.println(myByteString);

however, when it is printed out in the terminal it is in this form:

\n\325\a\nk\b\003\032\v\b\312\371\336\343\005\020\254\200\307S\

How can I display the string in ASCII characters instead of this encoding?

I have tried using System.out.println(myByteString.toString());

Thanks

like image 786
James Avatar asked May 19 '26 21:05

James


1 Answers

Try

System.out.println(myByteString.toString("UTF-8"));

or whatever encoding you are using.

Check out this link: Google Developers: Class ByteString

like image 57
Luk Avatar answered May 21 '26 10:05

Luk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!