Examples of asCharBuffer()


Examples of java.nio.ByteBuffer.asCharBuffer()

  public static CharBuffer newCharBuffer (int numChars) {
    if (GWT.isProdMode()) {
      ByteBuffer buffer = ByteBuffer.allocateDirect(numChars * 2);
      buffer.order(ByteOrder.nativeOrder());
      return buffer.asCharBuffer();
    } else {
      return CharBuffer.wrap(new char[numChars]);
    }
  }

View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

  public static CharBuffer newCharBuffer (int numChars) {
    if (GWT.isProdMode()) {
      ByteBuffer buffer = ByteBuffer.allocateDirect(numChars * 2);
      buffer.order(ByteOrder.nativeOrder());
      return buffer.asCharBuffer();
    } else {
      return CharBuffer.wrap(new char[numChars]);
    }
  }

View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

  }
 
  public static String encode(Charset encoding, String inStr) throws IOException {
    Charset koi = Charset.forName("KOI8-R");
    ByteBuffer bbuf = encoding.encode(CharBuffer.wrap(inStr));
    return bbuf.asCharBuffer().toString();
  }
  public static String decode(Charset encoding, InputStream is) {
    try {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Reader r = new InputStreamReader(is, "KOI8-R");
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

    public DatagramDownPacket getDatagramPacket() {
        DatagramDownPacket packet = new DatagramDownPacket();
        ArrayList list = new ArrayList();

        ByteBuffer buffer = ByteBuffer.allocate(1024);
        CharBuffer b = buffer.asCharBuffer();
        b.put("Hello! " + id++);

        buffer.position(b.position() * 2);
        buffer.flip();
        list.add(buffer);
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

                if ( !record.isCharData() )
                {
                    ByteBuffer buf = ByteBuffer.wrap( record.getData() );
                    char[] chars = new char[record.getData().length / 2];
                    totalSize += chars.length;
                    buf.asCharBuffer().get( chars );
                    charList.add( chars );
                }
                else
                {
                    charList.add( record.getDataAsChar() );
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

        assertEquals( doubleValue, verificationBuffer.getDouble(), 0.0 );
        byte[] actualBytes = new byte[bytesValue.length];
        verificationBuffer.get( actualBytes );
        assertThat( actualBytes, new ArrayMatches<byte[]>( bytesValue ) );
        char[] actualChars = new char[charsValue.length];
        verificationBuffer.asCharBuffer().get( actualChars );
        assertThat( actualChars, new ArrayMatches<char[]>( charsValue ) );
    }
   
    @Test
    public void readSmallPortions() throws IOException
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

        assertEquals( doubleValue, verificationBuffer.getDouble(), 0.0 );
        byte[] actualBytes = new byte[bytesValue.length];
        verificationBuffer.get( actualBytes );
        assertThat( actualBytes, new ArrayMatches<byte[]>( bytesValue ) );
        char[] actualChars = new char[charsValue.length];
        verificationBuffer.asCharBuffer().get( actualChars );
        assertThat( actualChars, new ArrayMatches<char[]>( charsValue ) );
    }
   
    @Test
    public void onlyOneFullBlock() throws Exception
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

            if ( !record.isCharData() )
            {
                ByteBuffer buf = ByteBuffer.wrap( record.getData() );
                char[] chars = new char[record.getData().length / 2];
                totalSize += chars.length;
                buf.asCharBuffer().get( chars );
                charList.add( chars );
            }
            else
            {
                charList.add( record.getDataAsChar() );
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

                if ( !record.isCharData() )
                {
                    ByteBuffer buf = ByteBuffer.wrap( record.getData() );
                    char[] chars = new char[record.getData().length / 2];
                    totalSize += chars.length;
                    buf.asCharBuffer().get( chars );
                    charList.add( chars );
                }
                else
                {
                    charList.add( record.getDataAsChar() );
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

            getNewMappedBuffer();
            if ( mappedBuffer == null )
            {
                int bytesToWrite = ( chars.length - offset ) * 2;
                ByteBuffer buf = ByteBuffer.allocate( bytesToWrite );
                buf.asCharBuffer().put( chars, offset, chars.length - offset );
                buf.limit( chars.length * 2 );
                int count = fileChannel.write( buf, mappedStartPosition );
                if ( count != bytesToWrite )
                {
                    throw new UnderlyingStorageException( "Failed to write from " +
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.