美文网首页
Java中byte[]和String的转换问题

Java中byte[]和String的转换问题

作者: Rimson | 来源:发表于2018-10-02 16:15 被阅读0次

    String转byte[]:

    String str="hello";
    byte[] strByte=str.getBytes();
    

    byte[]转String:

    String test=strByte.toString();
    String res = new String(srtByte);
    

    test不是"hello"
    res是"hello"

    相关文章

      网友评论

          本文标题:Java中byte[]和String的转换问题

          本文链接:https://www.haomeiwen.com/subject/qlhaoftx.html