package com.test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
public class BufferedOutputStream extends ServletOutputStream {
private ByteArrayOutputStream outputStream = null;
public BufferedOutputStream(){
outputStream = new ByteArrayOutputStream(1024);
}
/**
* Writes the specified byte to this output stream. The general
* contract for <code>write</code> is that one byte is written
* to the output stream. The byte to be written is the eight
* low-order bits of the argument <code>b</code>. The 24
* high-order bits of <code>b</code> are ignored.
* <p>
* Subclasses of <code>OutputStream</code> must provide an
* implementation for this method.
*
* @param b the <code>byte</code>.
* @exception IOException if an I/O error occurs. In particular,
* an <code>IOException</code> may be thrown if the
* output stream has been closed.
*/
public void write(int b) throws IOException {
outputStream.write(b);
}
/**
* Writes <code>b.length</code> bytes from the specified byte array
* to this output stream. The general contract for <code>write(b)</code>
* is that it should have exactly the same effect as the call
* <code>write(b, 0, b.length)</code>.
*
* @param b the data.
* @exception IOException if an I/O error occurs.
* @see java.io.OutputStream#write(byte[], int, int)
*/
public void write(byte b[]) throws IOException {
outputStream.write(b);
}
/**
* Writes <code>len</code> bytes from the specified byte array
* starting at offset <code>off</code> to this output stream.
* The general contract for <code>write(b, off, len)</code> is that
* some of the bytes in the array <code>b</code> are written to the
* output stream in order; element <code>b[off]</code> is the first
* byte written and <code>b[off+len-1]</code> is the last byte written
* by this operation.
* <p>
* The <code>write</code> method of <code>OutputStream</code> calls
* the write method of one argument on each of the bytes to be
* written out. Subclasses are encouraged to override this method and
* provide a more efficient implementation.
* <p>
* If <code>b</code> is <code>null</code>, a
* <code>NullPointerException</code> is thrown.
* <p>
* If <code>off</code> is negative, or <code>len</code> is negative, or
* <code>off+len</code> is greater than the length of the array
* <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs. In particular,
* an <code>IOException</code> is thrown if the output
* stream is closed.
*/
public void write(byte b[], int off, int len) throws IOException {
outputStream.write(b, off, len);
}
/**
* Writes a <code>String</code> to the client,
* without a carriage return-line feed (CRLF)
* character at the end.
*
*
* @param s the <code>String</code> to send to the client
*
* @exception IOException if an input or output exception occurred
*
*/
public void print(String s) throws IOException {
print(s, "UTF-8");
}
public void print(String s, String charsetName) throws IOException {
/*
* 解决中文乱码问题
*/
outputStream.write(s.getBytes(charsetName));
}
/**
* Writes a <code>boolean</code> value to the client,
* with no carriage return-line feed (CRLF)
* character at the end.
*
* @param b the <code>boolean</code> value
* to send to the client
*
* @exception IOException if an input or output exception occurred
*
*/
public void print(boolean b) throws IOException {
print(b?"true":"false");
}
/**
* Writes a character to the client,
* with no carriage return-line feed (CRLF)
* at the end.
*
* @param c the character to send to the client
*
* @exception IOException if an input or output exception occurred
*
*/
public void print(char c) throws IOException {
print(String.valueOf(c));
}
/**
*
* Writes an int to the client,
* with no carriage return-line feed (CRLF)
* at the end.
*
* @param i the int to send to the client
*
* @exception IOException if an input or output exception occurred
*
*/
public void print(int i) throws IOException {
print(String.valueOf(i));
}
/**
*
* Writes a <code>long</code> value to the client,
* with no carriage return-line feed (CRLF) at the end.
*
* @param l the <code>long</code> value
* to send to the client
*
* @exception IOException if an input or output exception
* occurred
*
*/
public void print(long l) throws IOException {
print(String.valueOf(l));
}
/**
*
* Writes a <code>float</code> value to the client,
* with no carriage return-line feed (CRLF) at the end.
*
* @param f the <code>float</code> value
* to send to the client
*
* @exception IOException if an input or output exception occurred
*
*
*/
public void print(float f) throws IOException {
print(String.valueOf(f));
}
/**
*
* Writes a <code>double</code> value to the client,
* with no carriage return-line feed (CRLF) at the end.
*
* @param d the <code>double</code> value
* to send to the client
*
* @exception IOException if an input or output exception occurred
*
*/
public void print(double d) throws IOException {
print(String.valueOf(d));
}
/**
* Writes a carriage return-line feed (CRLF)
* to the client.
*
*
*
* @exception IOException if an input or output exception occurred
*
*/
public void println() throws IOException {
print("\r\n");
}
/**
* Writes a <code>String</code> to the client,
* followed by a carriage return-line feed (CRLF).
*
*
* @param s the <code>String</code> to write to the client
*
* @exception IOException if an input or output exception occurred
*
*/
public void println(String s){
println(s, "UTF-8");
}
public void println(String s, String charsetName){
/*
* 解决中文乱码问题
*/
try {
print(s,charsetName);
println();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
*
* Writes a <code>boolean</code> value to the client,
* followed by a
* carriage return-line feed (CRLF).
*
*
* @param b th
没有合适的资源?快使用搜索试试~ 我知道了~
java实现gzip ajax请求gzip压缩
共27个文件
class:6个
java:6个
jar:3个
5星 · 超过95%的资源 需积分: 50 61 下载量 66 浏览量
2017-05-13
19:30:43
上传
评论
收藏 572KB ZIP 举报
温馨提示
java实现gzip ajax请求gzip压缩 等
资源推荐
资源详情
资源评论
收起资源包目录
He.zip (27个子文件)
He
.project 1KB
WebContent
WEB-INF
lib
servlet-api.jar 193KB
commons-io-1.3.2.jar 86KB
commons-lang-2.6.jar 278KB
web.xml 819B
index.html 592B
js
jquery.js 93KB
META-INF
MANIFEST.MF 39B
src
com
test
TestServlet.java 6KB
Test.java 92B
BufferedResponse.java 2KB
ZipUtil.java 739B
BufferedOutputStream.java 12KB
MyFilter.java 4KB
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 458B
.jsdtscope 503B
build
classes
com
test
BufferedResponse.class 2KB
ZipUtil.class 1KB
TestServlet.class 9KB
MyFilter.class 4KB
BufferedOutputStream.class 3KB
Test.class 373B
.classpath 842B
共 27 条
- 1
资源评论
- zongyan8882019-07-17资源不错,找了好久
- YelijahYang2018-12-24资源不错,找了好久
grace.free
- 粉丝: 598
- 资源: 82
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功