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这些框架时是学不明白的. 动态代理技术就是用来产生一个对象的代理对 ...
随机推荐
- ANT不完全总结,包含各种命令,ant例子等,转自:http://lavasoft.blog.51cto.com/62575/87306
ANT不完全总结 好久没有用Ant了,最近让MyEclipse.JBuilder2008逼的重回Ant上了.手生了,写了一个脚本后,重新总结下.参考了官方的文档和网上一些资料. 一.ANT的介 ...
- Appium webdriver的capabilities配置
Capabilities是由客户端发送给Appium服务器端的用来告诉服务器去启动哪种我们想要的会话的一套键值对集合.当中也有一些键值对是用来在自动化的过程中修改服务器端的行为方式. 必填的项目: d ...
- TensorFlow与OpenCV,读取图片,进行简单操作并显示
TensorFlow与OpenCV,读取图片,进行简单操作并显示 1 OpenCV读入图片,使用tf.Variable初始化为tensor,加载到tensorflow对图片进行转置操作,然后openc ...
- SQL Server 索引维护(1)——系统常见的索引问题
前言: 在很多系统中,比如本人目前管理的数据库,索引经常被滥用,甚至使用DTA(数据库引擎优化顾问)来成批创建索引(DTA目前个人认为它的真正用处应该是在发现缺失的统计信息,在以前的项目中,用过一次D ...
- Java集合-----java集合框架常见问题
1什么是Java集合API Java集合框架API是用来表示和操作集合的统一框架,它包含接口.实现类.以及帮助程序员完成一些编程的算法. 简言之,API在上层完成以下几件事: ● 编程更加省力,提高城 ...
- Java基本语法-----java数据类型的转换
前言 Java中可以进行不同数据类型的加减乘除运算吗?是可以的.在算术运算符中已经体验过如果两个整数(int)相除会去掉小数部分.如果需要保留小数部分,可以让除数或者被除数变为double类型的(5变 ...
- 【移动开发】一张图搞定Activity和Fragment的生命周期
- (NO.00005)iOS实现炸弹人游戏(六):游戏数据的初始化(三)
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 现在我们来看看实际初始化地图的randomCreateMap方法 ...
- android分包方案
当一个app的功能越来越复杂,代码量越来越多,也许有一天便会突然遇到下列现象: 1. 生成的apk在2.3以前的机器无法安装,提示INSTALL_FAILED_DEXOPT 2. 方法数量过多,编译时 ...
- Redefine:Change in the Changing World
EMC World 2014的主题就是REDEFINE.的确,现在科技的发展在重新定义了技术,影响了生活,改变了你我. 对于一个有数万员工,甚至数十万员工的企业来说,Redefine无疑更加具有挑战, ...