Converting a set of strings to a byte[] array

前端 未结 6 1071
甜味超标
甜味超标 2021-01-23 04:45

I am tring to convert a set of strings to a byte[] array. At first, I do something like this to convert a byte array to a string:

public String convertByte(byte[         


        
6条回答
  •  轮回少年
    2021-01-23 05:38

    If you are certain the String will be small enough to fit in one byte, you could do

    st[i].getBytes()[0];
    

    however, in most of the cases, your String will probably be bigger, so in these cases it is not possible...

提交回复
热议问题