📄 nakedbytestream.java
字号:
/*
* NakedByteStream.java -
*
* This file is part of the Jawin Project: http://jawinproject.sourceforge.net/
*
* Please consult the LICENSE file in the project root directory,
* or at the project site before using this software.
*/
/* $Id: NakedByteStream.java,v 1.3 2004/06/14 19:39:05 arosii_moa Exp $ */
package org.jawin.io;
import java.io.ByteArrayOutputStream;
/**
* works around the java ByteArray streams, which do not provide
* direct access to the byte array. Direct access can make programs
* trickier to debug but saves a System.arraycopy on every marshal!
* <br><br>
* <b>Important:</b> do NOT use .length on the returned array. See
* {@link #getInternalBuffer()} for details.
* <br><br>
* TODO this class should perhaps over time be
* modified to a java.nio.ByteBuffer.
*
* @version $Revision: 1.3 $
* @author Stuart Halloway, http://www.relevancellc.com/halloway/weblog/
*/
public class NakedByteStream extends ByteArrayOutputStream {
/**
* <b>Description copied from class: {@link ByteArrayOutputStream}</b><br>
* Creates a new byte array output stream. The buffer capacity is initially
* 32 bytes, though its size increases if necessary.
*/
public NakedByteStream() {
super();
}
/**
* <b>Description copied from class: {@link ByteArrayOutputStream}</b><br>
* Creates a new byte array output stream, with a buffer capacity of the
* specified size, in bytes
*
* @param size the initial size
* @throws IllegalArgumentException if size is negative.
*/
public NakedByteStream(int size) {
super(size);
}
/**
* for direct access to the byte array buffer.
* <br><br>
* Please notice that modifications to this NakedByteStream's content
* will cause the returned array's content to be modified, and vice versa.
* <br><br>
* <b>Important:</b> do NOT use .length on the returned array,
* as this is just the ("random") size of the buffer depending
* on how the NakedByteStream has been used. Instead use the
* {@link ByteArrayOutputStream#size()} to retrieve the length
* of the array with data.
*
* @return the internal byte array buffer
* @see ByteArrayOutputStream#buf
*/
public byte[] getInternalBuffer() {
return buf;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -