public void writeString(CharBuffer text) throws IllegalArgumentException, IOException { if (text == null) throw new IllegalArgumentException("text cannot be null"); int length = text.remaining(); // Write header if (length < 255) { write(STRING_COMPACT); write(length); } else { write(STRING); writeInt32Impl(length); } // Write body encoder.encode(text, out); }
public void writeHuge(CharBuffer huge) throws IllegalArgumentException, IOException { if (huge == null) throw new IllegalArgumentException("huge cannot be null"); int length = huge.remaining(); // Write header if (length < 255) { write(HUGE_COMPACT); write(length); } else { write(HUGE); writeInt32Impl(length); } // Write body encoder.encode(huge, out); }