monitoredoutputstream.java

来自「前期开发时开发的新闻发布系统」· Java 代码 · 共 45 行

JAVA
45
字号
package book.upload;

import java.io.OutputStream;
import java.io.IOException;

public class MonitoredOutputStream extends OutputStream 
{
	
	private OutputStream target;
	private OutputStreamListener listener;

	public MonitoredOutputStream(OutputStream target, OutputStreamListener listener) 
	{		
		this.target = target;
		this.listener = listener;
	}

	public void write(byte b[], int off, int len) throws IOException 
	{	
		target.write(b, off, len);
		listener.bytesRead(len - off);
	}

	public void write(byte b[]) throws IOException 
	{		
		target.write(b);
		listener.bytesRead(b.length);
	}

	public void write(int b) throws IOException 
	{		
		target.write(b);
		listener.bytesRead(1);
	}

	public void close() throws IOException 
	{		
		target.close();
	}

	public void flush() throws IOException 
	{		
		target.flush();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?