ByteBuffer buffer = ByteBuffer.allocate(1024);
buffer.put("aabcde".getBytes());
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
String s = new String(bytes);
위가 아니라 아래처럼 해야 됩니다. ^^;;
ByteBuffer buffer = ByteBuffer.allocate(1024);
buffer.put("aabcde".getBytes());
byte[] bytes = new byte[buffer.position()];
buffer.flip();
buffer.get(bytes);
String s = new String(bytes);
System.out.println(s);
buffer.put("aabcde".getBytes());
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
String s = new String(bytes);
위가 아니라 아래처럼 해야 됩니다. ^^;;
ByteBuffer buffer = ByteBuffer.allocate(1024);
buffer.put("aabcde".getBytes());
byte[] bytes = new byte[buffer.position()];
buffer.flip();
buffer.get(bytes);
String s = new String(bytes);
System.out.println(s);
'Java' 카테고리의 다른 글
| class file has wrong version 50.0, should be 4x.0 (0) | 2008/10/23 |
|---|---|
| Get and put unsigned values to a ByteBuffer (0) | 2008/10/07 |
| ByteBuffer to String (2) | 2008/09/30 |
| Convert int -> byte array and byte array -> int (0) | 2008/09/30 |
| POJO와 관련된 용어들.. (1) | 2008/09/24 |