/** * This is recommended to be used where there's more than 1 buffer to write, instead * use {@link #writeTo(java.io.Writer, String)} which auto detects if * {@link #writeToViaString(java.io.Writer, String)} is to be used or * {@link #writeToViaSmoosh(java.io.Writer, String)}. * * @param out * @param encoding * @throws IOException */ void writeToViaSmoosh(Writer out, String encoding) throws IOException { byte[] bufferToWrite = toByteArray(); int bufferToWriteLen = bufferToWrite.length; writeToImpl(out, encoding, bufferToWrite, bufferToWriteLen); }
public void write(int datum) throws IOException { if (closed) { throw new IOException("Stream closed"); } else { if (index == blockSize) { addBuffer(); } // store the byte buffer[index++] = (byte) datum; } }
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(estimatedByteLength); baos.write(TMO_EURO_BYTE); else { for (; search < CHAR_TABLE.length; search++) { baos.write(search); break; baos.write(0x3f); return baos.toByteArray();
@Override public String toString() { return new String(toByteArray()); }
writeToViaSmoosh(out, encoding); } else { writeToViaString(out, encoding);
/** * This can <b>ONLY</b> be called if there is only a single buffer to write, instead * use {@link #writeTo(java.io.Writer, String)}, which auto detects if * {@link #writeToViaString(java.io.Writer, String)} is to be used or * {@link #writeToViaSmoosh(java.io.Writer, String)}. * * @param out the JspWriter * @param encoding the encoding * @throws IOException */ void writeToViaString(Writer out, String encoding) throws IOException { byte[] bufferToWrite = buffer; // this is always the last buffer to write int bufferToWriteLen = index; // index points to our place in the last buffer writeToImpl(out, encoding, bufferToWrite, bufferToWriteLen); }
public byte[] toByteArray() { byte[] data = new byte[getSize()]; // Check if we have a list of buffers int pos = 0; if (buffers != null) { Iterator iter = buffers.iterator(); while (iter.hasNext()) { byte[] bytes = (byte[])iter.next(); System.arraycopy(bytes, 0, data, pos, blockSize); pos += blockSize; } } // write the internal buffer directly System.arraycopy(buffer, 0, data, pos, index); return data; }
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(estimatedByteLength); baos.write(TMO_EURO_BYTE); else { for (; search < CHAR_TABLE.length; search++) { baos.write(search); break; baos.write(0x3f); return baos.toByteArray();
@Override public String toString() { return new String(toByteArray()); }
writeToViaSmoosh(out, encoding); } else { writeToViaString(out, encoding);
/** * This can <b>ONLY</b> be called if there is only a single buffer to write, instead * use {@link #writeTo(java.io.Writer, String)}, which auto detects if * {@link #writeToViaString(java.io.Writer, String)} is to be used or * {@link #writeToViaSmoosh(java.io.Writer, String)}. * * @param out the JspWriter * @param encoding the encoding * @throws IOException */ void writeToViaString(Writer out, String encoding) throws IOException { byte[] bufferToWrite = buffer; // this is always the last buffer to write int bufferToWriteLen = index; // index points to our place in the last buffer writeToImpl(out, encoding, bufferToWrite, bufferToWriteLen); }
public byte[] toByteArray() { byte[] data = new byte[getSize()]; // Check if we have a list of buffers int pos = 0; if (buffers != null) { Iterator iter = buffers.iterator(); while (iter.hasNext()) { byte[] bytes = (byte[])iter.next(); System.arraycopy(bytes, 0, data, pos, blockSize); pos += blockSize; } } // write the internal buffer directly System.arraycopy(buffer, 0, data, pos, index); return data; }
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(estimatedByteLength); baos.write(search); break; baos.write(EXTENDED_ESCAPE); baos.write(search); break; baos.write(0x3f); return baos.toByteArray();
/** * This is recommended to be used where there's more than 1 buffer to write, instead * use {@link #writeTo(java.io.Writer, String)} which auto detects if * {@link #writeToViaString(java.io.Writer, String)} is to be used or * {@link #writeToViaSmoosh(java.io.Writer, String)}. * * @param out * @param encoding * @throws IOException */ void writeToViaSmoosh(Writer out, String encoding) throws IOException { byte[] bufferToWrite = toByteArray(); int bufferToWriteLen = bufferToWrite.length; writeToImpl(out, encoding, bufferToWrite, bufferToWriteLen); }
public void write(int datum) throws IOException { if (closed) { throw new IOException("Stream closed"); } else { if (index == blockSize) { addBuffer(); } // store the byte buffer[index++] = (byte) datum; } }
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(estimatedByteLength); baos.write(search); break; baos.write(EXTENDED_ESCAPE); baos.write(search); break; baos.write(0x3f); return baos.toByteArray();