Java-ServletOutputStream
/**
* Provides an output stream for sending binary data to the
* client. A <code>ServletOutputStream</code> object is normally retrieved
* via the {@link ServletResponse#getOutputStream} method.
*
* <p>This is an abstract class that the servlet container implements.
* Subclasses of this class
* must implement the <code>java.io.OutputStream.write(int)</code>
* method.
*
*
* @author Various
* @version $Version$
*
* @see ServletResponse
*
*/
//提供一个输出流来发送二进制数据给客户端,Servlet容器会实现这个类,这个类的子类一定要实现java.io.OutputStream.write(int)方法
public abstract class ServletOutputStream extends OutputStream {
private static final String LSTRING_FILE = "javax.servlet.LocalStrings";
private static ResourceBundle lStrings =
ResourceBundle.getBundle(LSTRING_FILE);
/**
* Does nothing, because this is an abstract class.
*/
//抽象类的构造函数
protected ServletOutputStream() { }
/**
* 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
*/
//向客户端写string
public void print(String s) throws IOException {
if (s==null) s="null";
int len = s.length();
for (int i = 0; i < len; i++) {
char c = s.charAt (i);
// XXX NOTE: This is clearly incorrect for many strings,
// but is the only consistent approach within the current
// servlet framework. It must suffice until servlet output
// streams properly encode their output.
//
if ((c & 0xff00) != 0) { // high order byte must be zero
String errMsg = lStrings.getString("err.not_iso8859_1");
Object[] errArgs = new Object[1];
errArgs[0] = new Character(c);
errMsg = MessageFormat.format(errMsg, errArgs);
throw new CharConversionException(errMsg);
}
write (c);
}
}
/**
* 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
*/
//向客户端写boolean
public void print(boolean b) throws IOException {
String msg;
if (b) {
msg = lStrings.getString("value.true");
} else {
msg = lStrings.getString("value.false");
}
print(msg);
}
/**
* 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
*/
//写int
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
*/
//写long
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
*/
//写float
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
*/
//写double
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
*/
//写string并回车
public void println(String s) throws IOException {
print(s);
println();
}
/**
* Writes a <code>boolean</code> value to the client,
* followed by a
* carriage return-line feed (CRLF).
* @param b the <code>boolean</code> value
* to write to the client
* @exception IOException if an input or output exception occurred
*/
//boolean 回车
public void println(boolean b) throws IOException {
print(b);
println();
}
/**
* Writes a character to the client, followed by a carriage
* return-line feed (CRLF).
* @param c the character to write to the client
* @exception IOException if an input or output exception occurred
*/
//字符 回车
public void println(char c) throws IOException {
print(c);
println();
}
/**
* Writes an int to the client, followed by a
* carriage return-line feed (CRLF) character.
* @param i the int to write to the client
* @exception IOException if an input or output exception occurred
*/
//int 回车
public void println(int i) throws IOException {
print(i);
println();
}
/**
* Writes a <code>long</code> value to the client, followed by a
* carriage return-line feed (CRLF).
* @param l the <code>long</code> value to write to the client
* @exception IOException if an input or output exception occurred
*/
//long 回车
public void println(long l) throws IOException {
print(l);
println();
}
/**
* Writes a <code>float</code> value to the client,
* followed by a carriage return-line feed (CRLF).
* @param f the <code>float</code> value to write to the client
* @exception IOException if an input or output exception occurred
*/
//float 回车
public void println(float f) throws IOException {
print(f);
println();
}
/**
* Writes a <code>double</code> value to the client,
* followed by a carriage return-line feed (CRLF).
* @param d the <code>double</code> value to write to the client
* @exception IOException if an input or output exception occurred
*/
//double 回车
public void println(double d) throws IOException {
print(d);
println();
}
}
Java-ServletOutputStream的更多相关文章
- Spark案例分析
一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...
- java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
扩展阅读:https://blog.csdn.net/kimylrong/article/details/50353161
- Java 条形码 二维码 的生成与解析
Barcode简介 Barcode是由一组按一定编码规则排列的条,空符号,用以表示一定的字符,数字及符号组成的,一种机器可读的数据表示方式. Barcode的形式多种多样,按照它们的外观分类: Lin ...
- Java Servlet规范
截自网址:http://blog.csdn.net/u010391029/article/details/46521051 JavaServlet Specification Version 2.3 ...
- solve the problem of 'java web project cannot display verification code'
my java code of the function: package com.util; import java.awt.Color; import java.awt.Font; import ...
- java web学习总结(十八) -------------------过滤器的高级使用
在filter中可以得到代表用户请求和响应的request.response对象,因此在编程中可以使用Decorator(装饰器)模式对request.response对象进行包装,再把包装对象传给目 ...
- java web学习总结(八) -------------------HttpServletResponse对象(二)
一.HttpServletResponse常见应用--生成验证码 1.1.生成随机图片用作验证码 生成图片主要用到了一个BufferedImage类,
- java系统高并发解决方案-转
转载博客地址:http://blog.csdn.net/zxl333/article/details/8685157 一个小型的网站,比如个人网站,可以使用最简单的html静态页面就实现了,配合一些图 ...
- JAVA文件下载功能问题解决日志
今天给报告系统做了个下载功能,遇到了挺多问题,通过查资料一一解决了. 1.首先遇到的问题是:java后台的输出流输出之后,没有任何报错,浏览器端不弹出保存文件的对话框,原本是ajax请求到后台的con ...
- Java基础知识:代理
一.代理的概念 动态代理技术是整个java技术中最重要的一个技术,它是学习java框架的基础,不会动态代理技术,那么在学习Spring这些框架时是学不明白的. 动态代理技术就是用来产生一个对象的代理对 ...
随机推荐
- PGM:图模型学习概述
http://blog.csdn.net/pipisorry/article/details/52571640 动机 前面我们讨论的问题出发点是给定一个图模型.如在独立性和推理讨论中,假定模型--结构 ...
- 针对于Python的OpenCV环境搭建
OpenCV 依赖 下载OpenCV 配置 总结 给Python搭建opencv的环境还真是略嫌麻烦,于是做下笔记,以备不时之需. OpenCV 依赖 opencv有些依赖,我们必须安装一下,否则接下 ...
- 解决Setting property 'source' to 'org.eclipse.jst.jee.server的问题
对于这个问题,我相信我的方法已经能帮90%的人解决了! 当你用Eclipse运行web项目的时候,你就会看到控制台出现: WARNING: [SetPropertiesRule]{Server/Ser ...
- T-SQL注意事项(1)——SET NOCOUNT ON的去与留
前言 用了一段时间T-SQL之后,哪怕自己没用过,也多多少少看过SSMS中的SET NOCOUNT ON命令,很多性能优化文章中都有提到这个东西,它们建议尽可能使用这个命令减少网络传输的压力,那么今天 ...
- JAVA面向对象-----抽象类注意细节
抽象类可以没有抽象方法(java.awt.*的类就是这样子操作的). 抽象类可以继承普通类与抽象类. 抽象类不能直接使用类名创建实例,但是有构造方法,构造方法是让子类进行初始化. 抽象类一定有构造方法 ...
- java虚拟机 jvm 局部变量表实战
java局部变量表是栈帧重要组中部分之一.他主要保存函数的参数以及局部的变量信息.局部变量表中的变量作用域是当前调用的函数.函数调用结束后,随着函数栈帧的销毁.局部变量表也会随之销毁,释放空间. 由于 ...
- CSDN帐号被封
感慨
- 今天我点亮了CSDN博客专家殊荣
很久以前,看着csdn博客学习第一篇博客时,我依旧记得,是一个名叫蒋老夫子的博客专家,文章写的非常认真.内心很崇拜.在想,若干年后,在哪个地方?以什么样的一种状态,也得到此殊荣,华为有句口号,叫勇敢做 ...
- 4.QT中进程操作,线程操作
QT中的线程操作 T19Process.pro SOURCES += \ main.cpp CONFIG += C++11 main.cpp #include <QCoreApplicat ...
- Java基础---Java---基础加强---内省的简单运用、注解的定义与反射调用、 自定义注解及其应用、泛型及泛型的高级应用、泛型集合的综合
内省的简单运用: JavaBean是一种特殊的Java类,主要用于传递数据信息,这种java类中的方法主要用于访问私有的字段,且方法名符合某种命名规则. 采用遍历BeanInfo的所有属性方式来查找和 ...