📄 bytearrayoutputtest.java
字号:
/* * Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN 188477749X * * http://nitric.com/jnp/ * * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */import java.io.*;
public class ByteArrayOutputTest {
static public void main (String[] args) throws IOException {
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream ();
byte[] buffer = new byte[16];
int numberRead;
while ((numberRead = System.in.read (buffer)) > -1)
byteArrayOut.write (buffer, 0, numberRead);
System.out.println ("Read " + byteArrayOut.size () + " bytes.");
System.out.write (byteArrayOut.toByteArray ());
PrintStream printStream = new PrintStream (byteArrayOut);
for (int i = 0; i < args.length; ++ i) {
printStream.println ("Written to " + args[i] + ".");
FileOutputStream fileOut = new FileOutputStream (args[i]);
byteArrayOut.writeTo (fileOut);
fileOut.close ();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -