Java Code Examples for java.nio.CharBuffer#duplicate()
The following examples show how to use
java.nio.CharBuffer#duplicate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: debug.java From antsdb with GNU Lesser General Public License v3.0 | 5 votes |
public static String dumpHex(CharBuffer buf) { StringBuilder s = new StringBuilder(); buf = buf.duplicate(); buf.position(0); for (int i=0; buf.hasRemaining(); i++) { char ch = buf.get(); String hex = BytesUtil.toHex(ch); s.append(hex); s.append(' '); if ((i > 0) && (i % 8 == 0)) { buf.append("\n"); } } return s.toString(); }
Example 2
Source File: Text.java From yajsync with GNU General Public License v3.0 | 5 votes |
public static String charBufferToString(CharBuffer buf) { StringBuilder sb = new StringBuilder(); CharBuffer dup = buf.duplicate(); sb.append("["); while (dup.hasRemaining()) { sb.append(dup.get()); if (dup.hasRemaining()) { sb.append(", "); } } return sb.append("]").toString(); }
Example 3
Source File: Text.java From yajsync with GNU General Public License v3.0 | 5 votes |
public static String charBufferToString(CharBuffer buf, int start, int end) { CharBuffer dup = buf.duplicate(); dup.position(start); dup.limit(end); return charBufferToString(dup); }
Example 4
Source File: MappeableRunContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
private MappeableRunContainer(int nbrruns, final CharBuffer valueslength) { this.nbrruns = nbrruns; CharBuffer tmp = valueslength.duplicate();// for thread safety this.valueslength = CharBuffer.allocate(Math.max(2 * nbrruns, tmp.limit())); tmp.rewind(); this.valueslength.put(tmp); // may copy more than it needs to?? }
Example 5
Source File: MappeableArrayContainer.java From RoaringBitmap with Apache License 2.0 | 5 votes |
private MappeableArrayContainer(int newCard, CharBuffer newContent) { this.cardinality = newCard; CharBuffer tmp = newContent.duplicate();// for thread-safety this.content = CharBuffer.allocate(Math.max(newCard, tmp.limit())); tmp.rewind(); this.content.put(tmp); }