How to efficiently convert byte array to string

前端 未结 5 1405
情深已故
情深已故 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条回答
  •  情深已故
    2020-12-17 19:37

    and here fantastic way (not efficient) :)

        byte[] b = { 48, 48, 49, 48, 48, 52 };
        ByteArrayInputStream bais = new ByteArrayInputStream(b);
    
        BufferedReader buf = new BufferedReader(new InputStreamReader(bais));
    
        String s = buf.readLine();
        System.out.println(s);
    

提交回复
热议问题