Package java.nio

Examples of java.nio.ByteBuffer.clear()


        // flush trailing encoded characters...
        if (buf.position() > 0)
        {
            sb.append(decode(buf, decoder));
            buf.clear();
        }

        return sb.toString();
    }
View Full Code Here


            // Create chunk set
            chunk = new HdfsDataFileChunk(fs, fs.getFileStatus(path));

            // Read the chunks
            for(int offset = 0; offset < numBytes; offset += jumps) {
                buffer.clear();
                assertEquals(chunk.read(buffer, offset), jumps);
                assertEquals(0, ByteUtils.compare(buffer.array(), ByteUtils.copy(randomBytes,
                                                                                 offset,
                                                                                 offset + jumps)));
            }
View Full Code Here

            while ((bytesRead = in.read(buffer)) != -1) {
                if (bytesRead < size) {
                    byteBuffer.limit(bytesRead);
                }
                out.write(byteBuffer);
                byteBuffer.clear();
            }
        } finally {
            IOHelper.close(in, target.getName(), LOG);
            IOHelper.close(out, target.getName(), LOG, endpoint.isForceWrites());
        }
View Full Code Here

    } catch(IllegalArgumentException iae) {
      // EXPECTED
    }

    // make a corrupted header
    inBuf.clear();
    inBuf.put((byte) 32);
    inBuf.put((byte) 0);
    inBuf.flip();
    in = InStream.create("test2", inBuf, codec, 300);
    try {
View Full Code Here

                } catch (IOException ex) {
                    break;
                }

                try {
                    data.clear();
                    request.read(data);
                } catch (Throwable ex) {}
            }

            try {
View Full Code Here

            while (read > 0) {
                read -= outChannel.write(buffer);
            }

            buffer.clear();
        }
    }

    private static boolean isLegalURIQueryChar(char c) {
        // http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html
View Full Code Here

                        // append characters literally
                    } finally {
                        if (bytes.position() > 0) {
                            bytes.flip();
                            buffer.append(Charsets.UTF_8.decode(bytes).toString());
                            bytes.clear();
                        }
                    }
                }
                buffer.append(url.charAt(i++));
            }
View Full Code Here

    double finished = System.currentTimeMillis();
   
    logger.info("done in " + (finished-started)/1000 + " seconds");
   
    for (ByteBuffer buf : test.values()) {
      buf.clear();
    }
  }

  private void pumpTheHeap(int ops, byte[] payload) {
View Full Code Here

    double finished = System.currentTimeMillis();
   
    logger.info("done in " + (finished-started)/1000 + " seconds");
   
    for (ByteBuffer buf : test.values()) {
      buf.clear();
    }
  }

  @BenchmarkOptions(benchmarkRounds = 5, warmupRounds = 0)
  @Test
View Full Code Here

    double finished = System.currentTimeMillis();
   
    logger.info("done in " + (finished-started)/1000 + " seconds");
   
    for (ByteBuffer buf : test.values()) {
      buf.clear();
    }
  }
 
}
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.