⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 monitoredoutputstream.java

📁 简单实用的ajax实例,包含动态数据加载、电子商务应用、自动及定时业务等小型实例
💻 JAVA
字号:
package ajax.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;
		this.listener.start();
	}

	// 覆盖方法
	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();
		listener.done();
	}

	// 覆盖方法
	public void flush() throws IOException {
		target.flush();
	}
}

⌨️ 快捷键说明

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