use bulk get()
This commit is contained in:
parent
89f060c8af
commit
0a18b2dca6
1 changed files with 2 additions and 4 deletions
|
@ -18,10 +18,8 @@ public class Text {
|
|||
public String toString() {
|
||||
byte[] bytes = new byte[this.size];
|
||||
|
||||
// why is there no absolute get() method on ByteArray?
|
||||
for (int ii = 0; ii < this.size; ++ii) {
|
||||
bytes[ii] = this.buffer.get(this.offset + ii);
|
||||
}
|
||||
this.buffer.position(this.offset);
|
||||
this.buffer.get(bytes, 0, this.size);
|
||||
|
||||
try {
|
||||
return new String(bytes, "UTF-8");
|
||||
|
|
Loading…
Reference in a new issue