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

📄 xteeinputstream.java

📁 XBrowser是一个完全免费并且开源的Web浏览器
💻 JAVA
字号:
/****************************************************************
*              XBrowser  -  eXtended web Browser                *
*                                                               *
*           Copyright (c) 2000-2001  Armond Avanes              *
*     Refer to ReadMe & License files for more information      *
*                                                               *
*                                                               *
*                 By: Uladzimir V. Kavalchuk                    *
*               Uladzimir_Kavalchuk@ep.minsk.by                 *
*               http://xbrowser.sourceforge.net/                *
*****************************************************************/
package xbrowser.renderer.custom;

import java.io.*;

/** InputStream that makes copy to file given.
 *
 *@author     Uladzimir_Kavalchuk
 *@created    June 12, 2001
 */
public class XTeeInputStream extends FilterInputStream {

	/**
	 *  Constructor for the TeeInputStream object
	 *
	 *@param  i  Description of Parameter
	 */
	public XTeeInputStream( InputStream i) {
		super(i);
	}

	/**
	 *  Description of the Method
	 *
	 *@return                  Description of the Returned Value
	 *@exception  IOException  Description of Exception
	 */
	public int read() throws IOException {
		int c = super.read();

		check();
		out.write( c);

		return c;
	}

	/**
	 *  Description of the Method
	 *
	 *@param  b                Description of Parameter
	 *@param  off              Description of Parameter
	 *@param  len              Description of Parameter
	 *@return                  Description of the Returned Value
	 *@exception  IOException  Description of Exception
	 */
	public int read(byte b[], int off, int len) throws IOException {
		int c = super.read(b, off, len);

		check();
        if( c > 0)
		    out.write(b, off, c);

		return c;
	}

	private void check() {
		if (out == null) {
			out = nos;
		}
	}

	/**
	 *  Sets the out attribute of the TeeInputStream class
	 *
	 *@param  fileName  The new FileOutputStream value
	 */
	public void setFileOutputStream( OutputStream fos) {
        out = fos;
	}

    public void close() throws IOException {
        super.close();
        check();
		out.flush();
        out.close();
    }

// Attributes:
	private OutputStream out; // = System.out;
    private static OutputStream nos = new OutputStream() {
        public void write( int c) {}
    };
}

⌨️ 快捷键说明

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