List of usage examples for java.nio CharBuffer slice
public abstract CharBuffer slice();
From source file:MainClass.java
public static void main(String argv[]) { ByteBuffer bb = ByteBuffer.allocate(100); bb.mark();/*from w w w . ja v a 2s. co m*/ bb.position(5); bb.reset(); bb.mark().position(5).reset(); char[] myBuffer = new char[100]; CharBuffer cb = CharBuffer.wrap(myBuffer); cb.position(12).limit(21); CharBuffer sliced = cb.slice(); System.out.println("Sliced: offset=" + sliced.arrayOffset() + ", capacity=" + sliced.capacity()); }
From source file:MainClass.java
public static void main(String[] argv) throws Exception { CharBuffer buffer = CharBuffer.allocate(8); buffer.position(3).limit(5);/* w w w . j a v a2 s . com*/ CharBuffer sliceBuffer = buffer.slice(); println(buffer); println(sliceBuffer); char[] myBuffer = new char[100]; CharBuffer cb = CharBuffer.wrap(myBuffer); cb.position(12).limit(21); CharBuffer sliced = cb.slice(); println(cb); println(sliced); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(50); cb1.append("java2s.com"); cb1.rewind();/* w ww .j a v a2 s . c om*/ System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = cb1.slice(); System.out.println(cb2.equals(cb1)); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(50); cb1.append("java2s.com"); cb1.rewind();//from w w w . j a v a 2 s . co m System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = cb1.slice(); System.out.println(cb2.compareTo(cb1)); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(50); cb1.append("java2s.com"); cb1.rewind();/*w w w . j a va2s .c o m*/ System.out.println(cb1.charAt(2)); System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = cb1.slice(); System.out.println(Arrays.toString(cb2.array())); }