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

📄 cachingoutputstream.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
字号:
package org.jasig.portal.serialize;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.OutputStream;import java.io.UnsupportedEncodingException;public class CachingOutputStream extends OutputStream implements CharacterCachingWriter {     OutputStream out;    ByteArrayOutputStream cache;    boolean caching;    public CachingOutputStream(OutputStream out) {        cache=null; caching=false;        this.out=out;    }    public boolean startCaching() throws IOException {        if(caching) return false;        flush();        caching=true;        cache=new ByteArrayOutputStream();        return true;    }    public String getCache(String encoding) throws UnsupportedEncodingException, IOException {        flush();        return cache.toString(encoding);    }    public boolean stopCaching() {        if(!caching) return false;        caching=false; return true;    }    public void close() throws IOException {        out.close();    }        public void flush() throws IOException {        if(out!=null) out.flush();        if(cache!=null) cache.flush();    }    public void write(byte[] b) throws IOException {        out.write(b);        if(caching) cache.write(b);    }    public void write(byte[] b, int off, int len) throws IOException {        out.write(b,off,len);        if(caching) cache.write(b,off,len);    }    public void write(int b) throws IOException {        out.write(b);        if(caching) cache.write(b);    }}

⌨️ 快捷键说明

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