How to convert String to byte without changing?

前端 未结 4 829
鱼传尺愫
鱼传尺愫 2021-01-29 07:28

I need a solution to convert String to byte array without changing like this:

Input:

 String s=\"Test\";

Output:

String         


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 08:08

    You can revert back using

    String originalString = new String(b, "UTF-8");

    That should get you back your original string. You don't want the bytes printed out directly.

提交回复
热议问题