List of usage examples for java.nio CharBuffer rewind
public final Buffer rewind()
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(10); cb1.append("java2s.com"); cb1.rewind(); System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = cb1.subSequence(0, 2); System.out.println(cb2);/*from ww w .ja v a 2 s .co m*/ }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(50); cb1.append("java2s.com"); cb1.rewind(); System.out.println(cb1.charAt(2)); System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = cb1.slice(); System.out.println(Arrays.toString(cb2.array())); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(50); cb1.append("java2s.com"); cb1.rewind(); System.out.println(cb1.charAt(2)); System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = cb1.compact(); System.out.println(Arrays.toString(cb2.array())); }
From source file:Main.java
public static void main(String[] args) throws IOException { CharBuffer cb1 = CharBuffer.allocate(20); cb1.append("java2s.com"); cb1.rewind(); System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = CharBuffer.allocate(50); cb2.read(cb1);//from w w w . jav a 2 s . c om System.out.println(cb2); }
From source file:Main.java
public static void main(String[] args) { char[] data = "UsingBuffers".toCharArray(); ByteBuffer bb = ByteBuffer.allocate(data.length * 2); CharBuffer cb = bb.asCharBuffer(); cb.put(data);//from ww w.j a va 2 s. c om System.out.println(cb.rewind()); symmetricScramble(cb); System.out.println(cb.rewind()); symmetricScramble(cb); System.out.println(cb.rewind()); }
From source file:MainClass.java
public static void main(String[] args) { char[] data = "UsingBuffers".toCharArray(); ByteBuffer bb = ByteBuffer.allocate(data.length * 2); CharBuffer cb = bb.asCharBuffer(); cb.put(data);//from w w w .j a v a 2s .c o m System.out.println(cb.rewind()); symmetricScramble(cb); System.out.println(cb.rewind()); symmetricScramble(cb); System.out.println(cb.rewind()); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(5); cb1.put('j').put('a').put('v').put('a').put('2').put('s'); ;/* w w w . j a v a2 s. c o m*/ cb1.rewind(); System.out.println(cb1.toString()); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(5); cb1.put(new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm', }); cb1.rewind(); System.out.println(cb1.toString()); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(5); cb1.put(new char[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm', }); cb1.rewind(); CharBuffer cb2 = CharBuffer.allocate(5); cb2.put(cb1);// ww w.ja v a 2 s . com System.out.println(cb2.toString()); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(5), cb2 = CharBuffer.allocate(5); cb1.put('B').put('u').put('f').put('f').put('A'); cb2.put('B').put('u').put('f').put('f').put('B'); cb1.rewind(); cb2.rewind();//from w ww.ja v a 2s .c o m System.out.println(cb1.limit(4).equals(cb2.limit(4))); }