Programming Tips - Java: Best way to convert a ByteBuffer to a String

Date: 2013apr28 Language: Java Class: NIO Q. Java: Best way to convert a ByteBuffer to a String A. Use the 4-parameter constructor of String
int bytesRead = sc.read(bb); String reply = new String(bb.array(), 0, bytesRead, "UTF-8");