class Buffered extends BufferedInputStream
{
Buffered(InputStream in,int size) //因为BufferedInputStream中的byte[]数组的buf是被protected修饰的,
{ //所以想要获得调用它的方法就是变成BufferedInputStream的子类。
super(in,size); //(这是之前在网上了解BufferedInputStream的默认buf数组容量时发现的方法,学以致用,O(∩_∩)O~)
}
Buffered(InputStream in)
{
super(in);
}
public static void main(String[] args)throws Exception
{
long start = System.currentTimeMillis();
long startTime = System.nanoTime();
Buffered bis = new Buffered(new FileInputStream
("F:\\KuGouCache\\Java核心技术,卷1(原书第8版).pdf"),1024*1024*2);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("F:\\KuGouCache\\Java.pdf"));
int i = 0;
while((i=bis.read())!=-1)
{
sop(bis.buf.length);
sop(bis.count);
sop("每次写入的:::"+i);
bos.write(i); //bis.buf / i
sop("写入之后:::"+bis.count);
}
bis.close();
bos.close();
long C = System.currentTimeMillis() - start;
long estimatedTime = System.nanoTime() - startTime;