List of usage examples for java.nio CharBuffer array
public final char[] array()
From source file:Main.java
public static void main(String[] args) throws Exception { byte[] invalidBytes = " ".getBytes(); byte[] validBytes = "(c)".getBytes(); CharsetDecoder decoder = Charset.forName("US-ASCII").newDecoder(); CharBuffer buffer = decoder.decode(ByteBuffer.wrap(validBytes)); System.out.println(Arrays.toString(buffer.array())); buffer = decoder.decode(ByteBuffer.wrap(invalidBytes)); System.out.println(Arrays.toString(buffer.array())); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(5); cb1.put(2, 'j'); cb1.rewind();//from www.j av a2s .co m System.out.println(Arrays.toString(cb1.array())); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(5); cb1.append('j'); cb1.rewind();// ww w . jav a2 s. c o m System.out.println(Arrays.toString(cb1.array())); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(50); cb1.append("java2s.com"); cb1.rewind();//from ww w .j a v a 2 s.c o m System.out.println(Arrays.toString(cb1.array())); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(5); cb1.append("java2s.com", 0, 4); cb1.rewind();//from w ww .ja va 2s . c o m System.out.println(Arrays.toString(cb1.array())); }
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 av a 2s . c o m*/ 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();//w ww .ja va 2s . 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(10); cb1.append("java2s.com"); cb1.rewind();/*from www . j a va2 s. co m*/ System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = cb1.subSequence(0, 2); System.out.println(cb2); }
From source file:Main.java
public static void main(String[] args) throws IOException { CharBuffer cb1 = CharBuffer.allocate(20); cb1.append("java2s.com"); cb1.rewind();/*w ww . j a v a2 s. c o m*/ System.out.println(Arrays.toString(cb1.array())); CharBuffer cb2 = CharBuffer.allocate(50); cb2.read(cb1); System.out.println(cb2); }
From source file:Main.java
public static void main(String[] args) { CharBuffer cb1 = CharBuffer.allocate(50); cb1.append("java2s.com"); cb1.rewind();//from w ww.j a v a 2 s.c o m System.out.println(cb1.charAt(2)); System.out.println(Arrays.toString(cb1.array())); }