List of utility methods to do ByteBuffer Write
void | writeStringArray(ByteBuffer buf, String[] array) write String Array buf.putInt(array.length); for (int i = 0; i < array.length; i++) { writeString(buf, array[i]); |
void | writeStringData(ByteBuffer buff, String s, int len) Write characters from a string (without the length). for (int i = 0; i < len; i++) { int c = s.charAt(i); if (c < 0x80) { buff.put((byte) c); } else if (c >= 0x800) { buff.put((byte) (0xe0 | (c >> 12))); buff.put((byte) (((c >> 6) & 0x3f))); buff.put((byte) (c & 0x3f)); ... |
void | writeStringToBuffer(ByteBuffer buffer, String message) write bytes to buffer and flip buffer.clear(); buffer.put(message.getBytes()); buffer.flip(); |
void | writeTo(ByteBuffer buffer, File file) write To FileChannel out = null; try { out = new FileOutputStream(file).getChannel(); out.write(buffer); } finally { closeQuietly(out); |
void | writeToChannel(final WritableByteChannel destChannel, final ByteBuffer buffer) write To Channel try { destChannel.write(buffer); buffer.compact(); buffer.flip(); while (buffer.hasRemaining()) { destChannel.write(buffer); } catch (IOException ex) { ... |
void | writeToChannel(WritableByteChannel chan, ByteBuffer buffer) Writes the content of the buffer to the given channel. buffer.rewind();
while (buffer.hasRemaining()) {
chan.write(buffer);
|
int | writeToChannel(WritableByteChannel dst, ByteBuffer src) Reads available data from the stream until the stream is empty or the java.nio.ByteBuffer is full int totalBytesWritten = 0; int bytesWritten; do { bytesWritten = dst.write(src); totalBytesWritten += bytesWritten; } while (bytesWritten > 0); return totalBytesWritten; |
void | writeToFile(String name, ByteBuffer bb) write To File try { File file = new File(name); boolean append = false; FileOutputStream fos = new FileOutputStream(file, append); FileChannel wChannel = fos.getChannel(); bb.rewind(); wChannel.write(bb); wChannel.force(true); ... |
void | writeTs(ByteBuffer is, long ts) write Ts is.put((byte) ((ts >> 29) << 1)); is.put((byte) (ts >> 22)); is.put((byte) ((ts >> 15) << 1)); is.put((byte) (ts >> 7)); is.put((byte) (ts >> 1)); |
void | writetUnsignedInt(ByteBuffer buffer, long value) Write the given long value as a 4 byte unsigned integer. buffer.putInt((int) (value & 0xffffffffL));
|