public void write(int b) { ensureCapacity(1); buf[pos++]=(byte)b; }
public void write(byte[] b, int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) - b.length > 0)) throw new IndexOutOfBoundsException(String.format("off=%d, len=%d, b.length=%d", off, len, b.length)); ensureCapacity(len); System.arraycopy(b, off, buf, pos, len); pos+=len; }
public void writeBytes(String s) { int len=s != null? s.length() : 0; if(len > 0) ensureCapacity(len); for(int i = 0 ; i < len ; i++) write((byte)s.charAt(i)); }
public void writeChars(String s) { int len=s != null? s.length() : 0; if(len > 0) ensureCapacity(len *2); // 2 bytes per char for(int i = 0 ; i < len ; i++) { int v = s.charAt(i); writeChar(v); } }
public void writeUTF(String str) { int strlen=str != null? str.length() : 0; if(strlen > 0) ensureCapacity(strlen *2 + 2);
public void write(int b) { ensureCapacity(1); buf[pos++]=(byte)b; }
public void write(byte[] b, int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) - b.length > 0)) throw new IndexOutOfBoundsException(String.format("off=%d, len=%d, b.length=%d", off, len, b.length)); ensureCapacity(len); System.arraycopy(b, off, buf, pos, len); pos+=len; }
public void writeChars(String s) { int len=s != null? s.length() : 0; if(len > 0) ensureCapacity(len *2); // 2 bytes per char for(int i = 0 ; i < len ; i++) { int v = s.charAt(i); writeChar(v); } }
public void writeBytes(String s) { int len=s != null? s.length() : 0; if(len > 0) ensureCapacity(len); for(int i = 0 ; i < len ; i++) write((byte)s.charAt(i)); }
public void writeUTF(String str) { int strlen=str != null? str.length() : 0; if(strlen > 0) ensureCapacity(strlen *2 + 2);