How to efficiently convert byte array to string

前端 未结 5 1396
情深已故
情深已故 2020-12-17 18:59

I have a byte array of 151 bytes which is typically a record, The record needs to inserted in to a oracle database. In 151 byte of array range from 0 to 1 is a record id , 2

5条回答
  •  萌比男神i
    2020-12-17 19:46

    Use the String(bytes[] bytes, int offset, int length) constructor: http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#String(byte[], int, int)

    new String(b, 0, 5);
    

提交回复
热议问题