Package java.nio

Examples of java.nio.Buffer


        // Write them out, read what we wrote and check it
        client.write(buffers);
        ByteBuffer readBuffer = ByteBuffer.allocate(1024);
        worker.read(readBuffer);
        readBuffer.flip();
        Buffer expected = ByteBuffer.allocate(1024).put(data).put(data).flip();
        assertEquals(expected, readBuffer);

        // Tidy-up
        worker.close();
        client.close();
View Full Code Here


  public static OpenEXRImage read(ImageInputStream source) throws IOException {
    return new OpenEXRImage(source);
  }

  private Buffer getChannelBuffer(String name) {
    Buffer buf = data.get(name);
    return buf != null ? buf : getChannelBufferSync(name);
  }
View Full Code Here

    Buffer buf = data.get(name);
    return buf != null ? buf : getChannelBufferSync(name);
  }

  private synchronized Buffer getChannelBufferSync(String name) {
    Buffer buf = data.get(name);
    if (buf == null) {
      ChannelList chlist = getChannelList();
      Channel channel = chlist.getChannel(name);
      Box2i dataWindow = getDataWindow();
      int w = dataWindow.getXSize();
View Full Code Here

          int sx = channel.getxSampling();
          int sy = channel.getySampling();
          if (y % sy == 0) {
            int nx = 1 + (x1 - x0 - (x1 % sx)) / sx;
            int offset = ((y - ymin) / sy) * nx;
            Buffer chBuf = getChannelBuffer(name);
            PixelType pt = channel.getPixelType();

            switch (pt) {
            case UINT:
              bytes.asIntBuffer().put((IntBuffer)
View Full Code Here

         int chunkSize = 10; // 10K
         int chunkId = 0;

         CharBuffer cbuf = CharBuffer.allocate(1024 * chunkSize);
         while (bufferedReader.read(cbuf) >= 0) {
            Buffer buffer = cbuf.flip();
            String textChunk = buffer.toString();
            cache.put(textFile + (chunkId++), textChunk);
            cbuf.clear();
            if (chunkId % 100 == 0) System.out.printf("  Inserted %s chunks from %s into grid%n", chunkId, textFile);
         }
      } finally {
View Full Code Here

        return ((Buffer) o).array();
    }

    @Override
    public int offset(Object o) {
        Buffer buffer = (Buffer) o;
        return buffer.arrayOffset() + buffer.position();
    }
View Full Code Here

        return ((Buffer) o).array();
    }

    @Override
    public int offset(Object o) {
        Buffer buffer = (Buffer) o;
        return buffer.arrayOffset() + buffer.position();
    }
View Full Code Here

        bs.dbuffer = ((ByteBuffer)bs.buffer).asDoubleBuffer();
        bs.write();
    }
    public void testBufferFieldReadUnchanged() {
        BufferStructure bs = new BufferStructure();
        Buffer b = ByteBuffer.allocateDirect(16);
        bs.buffer = b;
        bs.dbuffer = ((ByteBuffer)bs.buffer).asDoubleBuffer();
        bs.write();
        bs.read();
        assertEquals("Buffer field should be unchanged", b, bs.buffer);
View Full Code Here

TOP

Related Classes of java.nio.Buffer

Copyright © 2018 www.massapicom. 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.