本文整理了Java中org.apache.commons.io.output.ByteArrayOutputStream.size()
方法的一些代码示例,展示了ByteArrayOutputStream.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteArrayOutputStream.size()
方法的具体详情如下:
包路径:org.apache.commons.io.output.ByteArrayOutputStream
类名称:ByteArrayOutputStream
方法名:size
[英]Return the current size of the byte array.
[中]返回字节数组的当前大小。
代码示例来源:origin: commons-io/commons-io
private void checkStreams(
final ByteArrayOutputStream actual,
final java.io.ByteArrayOutputStream expected) {
assertEquals("Sizes are not equal", expected.size(), actual.size());
final byte[] buf = actual.toByteArray();
final byte[] refbuf = expected.toByteArray();
checkByteArrays(buf, refbuf);
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_byteArrayToWriter() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
@SuppressWarnings("resource") // deliberately not closed
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
final Writer writer = new OutputStreamWriter(baout, "US-ASCII");
IOUtils.write(inData, writer);
out.off();
writer.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite() throws Exception {
proxied.write('y');
assertEquals(1, original.size());
assertEquals('y', original.toByteArray()[0]);
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_byteArrayToWriter_Encoding_nullEncoding() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
@SuppressWarnings("resource") // deliberately not closed
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
final Writer writer = new OutputStreamWriter(baout, "US-ASCII");
IOUtils.write(inData, writer, (String) null);
out.off();
writer.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_stringToWriter_Encoding_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
@SuppressWarnings("resource") // deliberately not closed
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
final Writer writer = new OutputStreamWriter(baout, "US-ASCII");
IOUtils.write((String) null, writer);
out.off();
writer.flush();
assertEquals("Sizes differ", 0, baout.size());
}
代码示例来源:origin: commons-io/commons-io
@Test
public void copy_stringToWriter() throws Exception {
final String str = new String(inData, "US-ASCII");
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
final Writer writer = new java.io.OutputStreamWriter(out, "US-ASCII");
CopyUtils.copy(str, writer);
writer.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_charSequenceToOutputStream() throws Exception {
final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII"));
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write(csq, out);
out.off();
out.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_charSequenceToOutputStream_nullEncoding() throws Exception {
final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII"));
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write(csq, out, (String) null);
out.off();
out.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_charArrayToOutputStream_nullEncoding() throws Exception {
final String str = new String(inData, "US-ASCII");
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write(str.toCharArray(), out, (String) null);
out.off();
out.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_charArrayToOutputStream() throws Exception {
final String str = new String(inData, "US-ASCII");
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write(str.toCharArray(), out);
out.off();
out.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_stringToOutputStream() throws Exception {
final String str = new String(inData, "US-ASCII");
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write(str, out);
out.off();
out.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_stringToOutputStream_nullEncoding() throws Exception {
final String str = new String(inData, "US-ASCII");
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write(str, out, (String) null);
out.off();
out.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWriteLines_Writer_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
@SuppressWarnings("resource") // deliberately not closed
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
final Writer writer = new OutputStreamWriter(baout, "US-ASCII");
IOUtils.writeLines(null, "*", writer);
out.off();
writer.flush();
assertEquals("Sizes differ", 0, baout.size());
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_byteArrayToOutputStream() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write(inData, out);
out.off();
out.flush();
assertEquals("Sizes differ", inData.length, baout.size());
assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray()));
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_byteArrayToOutputStream_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write((byte[]) null, out);
out.off();
out.flush();
assertEquals("Sizes differ", 0, baout.size());
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_charArrayToOutputStream_Encoding_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write((char[]) null, out);
out.off();
out.flush();
assertEquals("Sizes differ", 0, baout.size());
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_charSequenceToOutputStream_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write((CharSequence) null, out);
out.off();
out.flush();
assertEquals("Sizes differ", 0, baout.size());
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWrite_stringToOutputStream_Encoding_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true);
IOUtils.write((String) null, out);
out.off();
out.flush();
assertEquals("Sizes differ", 0, baout.size());
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWriteLines_OutputStream_Encoding_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
IOUtils.writeLines(null, "*", out, "US-ASCII");
out.off();
out.flush();
assertEquals("Sizes differ", 0, baout.size());
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testWriteLines_OutputStream_nullData() throws Exception {
final ByteArrayOutputStream baout = new ByteArrayOutputStream();
final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true);
IOUtils.writeLines(null, "*", out);
out.off();
out.flush();
assertEquals("Sizes differ", 0, baout.size());
}
内容来源于网络,如有侵权,请联系作者删除!