[IT]/컴퓨터
[JAVA][예제] OutputBufferTest 예제 - Beginning Java Networking
jamesku
2012. 10. 2. 00:49
Beginning Java Networking
Chad Darby, www.wrox.com
// OutputBufferTest.java import java.io.IOException; import java.io.ByteArrayOutputStream; import java.io.BufferedOutputStream; public class OutputBufferTest { public OutputBufferTest() { } public static void main(String args[]) { try { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(byteOut); bos.write(new byte[255]); System.out.println("We've written 255 bytes and the byte stream shows:" + byteOut.size() +" bytes"); bos.flush(); System.out.println("After flushing the buffer, the byte stream shows:" + byteOut.size() +" bytes"); } catch (IOException ioe) { ioe.printStackTrace(); } } }