forked from TimSongCoder/LearnJavaForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByteBufferWR.java
More file actions
23 lines (18 loc) · 740 Bytes
/
Copy pathByteBufferWR.java
File metadata and controls
23 lines (18 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.nio.ByteBuffer;
public class ByteBufferWR{
public static void main(String[] args){
ByteBuffer buffer1 = ByteBuffer.allocate(7);
System.out.println("Capacity: " + buffer1.capacity());
System.out.println("Limit: " + buffer1.limit());
System.out.println("Position: " + buffer1.position());
System.out.println("Remaing: " + buffer1.remaining());
buffer1.put((byte)10).put((byte)20).put((byte)30);
System.out.println("Capacity: " + buffer1.capacity());
System.out.println("Limit: " + buffer1.limit());
System.out.println("Position: " + buffer1.position());
System.out.println("Remaing: " + buffer1.remaining());
for(int i=0;i<buffer1.position();i++){
System.out.println(buffer1.get(i));
}
}
}