Java-ServletInputStream
import java.io.InputStream;
import java.io.IOException;
/**
* Provides an input stream for reading binary data from a client
* request, including an efficient <code>readLine</code> method
* for reading data one line at a time. With some protocols, such
* as HTTP POST and PUT, a <code>ServletInputStream</code>
* object can be used to read data sent from the client.
* <p>A <code>ServletInputStream</code> object is normally retrieved via
* the {@link ServletRequest#getInputStream} method.
* <p>This is an abstract class that a servlet container implements.
* Subclasses of this class
* must implement the <code>java.io.InputStream.read()</code> method.
* @author Various
* @version $Version$
* @see ServletRequest
*/
public abstract class ServletInputStream extends InputStream {
/**
* Does nothing, because this is an abstract class.
*
*/
//抽象类,空构造函数
protected ServletInputStream() { }
/**
* Reads the input stream, one line at a time. Starting at an
* offset, reads bytes into an array, until it reads a certain number
* of bytes or reaches a newline character, which it reads into the
* array as well.
* <p>This method returns -1 if it reaches the end of the input
* stream before reading the maximum number of bytes.
* @param b an array of bytes into which data is read
* @param off an integer specifying the character at which this method begins reading
* @param len an integer specifying the maximum number of bytes to read
* @return an integer specifying the actual number of bytes read, or -1 if the end of the stream is reached
* @exception IOException if an input or output exception has occurred
*/
public int readLine(byte[] b, int off, int len) throws IOException {
if (len <= 0) {
return 0;
}
int count = 0, c;
while ((c = read()) != -1) {
b[off++] = (byte)c;
count++;
if (c == '\n' || count == len) {
break;
}
}
return count > 0 ? count : -1;
}
}
Java-ServletInputStream的更多相关文章
- Spark案例分析
一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...
- Solr7部署报错:java.lang.NoSuchMethodError: javax.servlet.ServletInputStream.isFinished()Z
错误信息: Servlet.service() for servlet [default] in context with path [/solr] threw exception [Filter e ...
- java.lang.NoClassDefFoundError: javax/servlet/ServletInputStream
转自:https://blog.csdn.net/y970105/article/details/355401 进入 tomcat根目录/lib/servlet-api.jar复制出来,放到JDK_P ...
- JAVA过滤器
对于get请求和post请求全局过滤: 自己创建一个类,实现HttpServletRequestWrapper接口 package com.dh.deno; import java.io.Buffer ...
- Android使用HttpURLConnection通过POST方式发送java序列化对象
使用HttpURLConnection类不仅可以向WebService发送字符串,还可以发送序列化的java对象,实现Android手机和服务器之间的数据交互. Android端代码: public ...
- [Java面试三]JavaWeb基础知识总结.
1.web服务器与HTTP协议 Web服务器 l WEB,在英语中web即表示网页的意思,它用于表示Internet主机上供外界访问的资源. l Internet上供外界访问的Web资源分为: • 静 ...
- Java Web之请求和响应
Servlet最主要作用就是处理客户端请求并作出回应,为此,针对每次请求,Web容器在调用service()之前都会创建两个对象,分别是HttpServletRequest和HttpServletRe ...
- Flash 二进制传图片到后台Java服务器接收
需求:把客户端处理过的图片返还给服务器Flash端代码 01 package {02 import com.adobe.images.JPGEncoder; 03 import ...
- Java中实现文件上传下载的三种解决方案
第一点:Java代码实现文件上传 FormFile file=manform.getFile(); String newfileName = null; String newpathname=null ...
- 【原创】用JAVA实现大文件上传及显示进度信息
用JAVA实现大文件上传及显示进度信息 ---解析HTTP MultiPart协议 (本文提供全部源码下载,请访问 https://github.com/grayprince/UploadBigFil ...
随机推荐
- MongoDB实用教程
---------------------------------------------------------------------------------------------------- ...
- 如何使用Live CD来修复Grub / Grub2
Introduction 一般我会在计算机上装两个或者多个系统,例如,我在计算机上安装了Ubuntu.Windows 7.Windows 8.1.有一天我的Win8.1不能正常使用了,我想重新安装Wi ...
- 分析RunTime执行命令以及得到返回值
RunTime执行命令得到返回值 我们有在好好几篇博客里提到过RunTime,比如 JAVA之旅(二十三)--System,RunTime,Date,Calendar,Math的数学运算 Androi ...
- 浅谈机器人控制与仿真设计----RDS和ROS
机器人控制.仿真或实验,主要由三个部分组成,机器人.环境和算法. 当然各部分又包含很多子部分和功能,这里主要以仿真为主,为了使得仿真结果能够直接应用到实际机器人上,这里分别以RDS和ROS对比介绍.h ...
- 全废话SQL Server统计信息(2)——统计信息基础
接上文:http://blog.csdn.net/dba_huangzj/article/details/52835958 我想在大地上画满窗子,让所有习惯黑暗的眼睛都习惯光明--顾城<我是一个 ...
- 深入了解UIViewController控制器与对应的View类的详解
ViewController是iOS开发中MVC模式中的C(视图控制器),ViewController是view的controller,ViewController的职责主要包括管理内部各个view的 ...
- Android Studio 不得不知的20大快捷键
如何进入设置快捷键的界面: Android Studio -> References -> Keymap 使用的Keymaps为 Eclipse(Mac OS X)如下图所示: 1 展开和 ...
- TCP的发送系列 — tcp_sendmsg()的实现(一)
主要内容:Socket发送函数在TCP层的实现 内核版本:3.15.2 我的博客:http://blog.csdn.net/zhangskd 上一篇blog讲的是send().sendto().sen ...
- Android计时器Chronometer-android学习之旅(二十一)
Chronometer简介 Chronometer和DigitalColok都继承与TextView,但是Chronometer不是显示的当前时间,而是从某个时间开始又过去了多少时间,是一个时间差. ...
- android开源库发布到jcenter图文详解与填坑
相信很多人都用过开源项目,特别是android studio普及以后,使用开源库更方便简单.而如何上传开源库到jcenter供大家方便使用,虽然网上也有教程,但还是遇坑了,最后总结一下,希望可以帮助大 ...