How to convert a Java String to an ASCII byte array?

后端 未结 10 510
心在旅途
心在旅途 2020-12-01 04:28

How to convert a Java String to an ASCII byte array?

10条回答
  •  鱼传尺愫
    2020-12-01 04:47

    If you happen to need this in Android and want to make it work with anything older than FroYo, you can also use EncodingUtils.getAsciiBytes():

    byte[] bytes = EncodingUtils.getAsciiBytes("ASCII Text");
    

提交回复
热议问题