更新时间:2022-06-12 06:05:48
InputStream
和 OutputStream
的目标是抽象不同的输入输出方式:是文件、网页还是屏幕应该无关紧要.重要的是您从流中接收信息(或将信息发送到流中.)
The goal of InputStream
and OutputStream
is to abstract different ways to input and output: whether the stream is a file, a web page, or the screen shouldn't matter. All that matters is that you receive information from the stream (or send information into that stream.)
InputStream
用于您读取的许多内容.
InputStream
is used for many things that you read from.
OutputStream
用于您写入的许多内容.
OutputStream
is used for many things that you write to.
这是一些示例代码.它假设 InputStream instr
和 OutputStream osstr
已经创建:
Here's some sample code. It assumes the InputStream instr
and OutputStream osstr
have already been created:
int i;
while ((i = instr.read()) != -1) {
osstr.write(i);
}
instr.close();
osstr.close();