第1个回答 2011-11-02
你好,我按照你的要求写了个简单的代码,请参阅
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class Testsyn {
public static void main(String[] args) throws IOException {
InputStream in = new BufferedInputStream(System.in);//比如输入流来控制台
byte[] array = new byte[100];
in.read(array, 0, 10);//只从输入流中读取10个字节到array数组里
OutputStream out = new FileOutputStream(new File("d:\\1.txt"));//输出流到d:\1.txt
out.write(array, 0, 5);//可以只写5个字节
}
}本回答被网友采纳