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 ...
随机推荐
- Xcode 中的断言
转自:http://weibo.com/p/100808885591f113cdedc3301794e5e7d7e9f0/home?from=page_100808&mod=TAB#_rnd1 ...
- Android程序员必须掌握的知识点-多进程和多线程
当某个应用组件启动且该应用没有运行其他任何组件时,Android 系统会使用单个执行线程为应用启动新的 Linux 进程.默认情况下,同一应用的所有组件在相同的进程和线程(称为"主" ...
- ROS(indigo) turtlebot2 + android一些有趣应用
ROS和Android配合使用非常有趣,这里推荐,ROSClinet,使用rosbridge让android和ROS通信: 具体参考奥斯卡的个人剧场:http://xxhong.net/ turtle ...
- FORM开发之键性弹性域开发
1.创建表时带有键弹性域字段 SUMMARY_FLAG VARCHAR2(1) , /* 必须有此字段 */ ENABLED_FLAG VARCHAR2(1) , /* 必须有此字段 */ START ...
- Linux & Windows 计时函数
直接上代码: #if defined(_WIN32) && defined(_MSC_VER) #include <windows.h> double abtic() { ...
- Html书写规范,基本标签使用
一.html简介1.html是什么Html是用来描述网页的一种语言.(1)HTML 指的是超文本标记语言 (Hyper Text Markup Language)(2)HTML 不是一种编程语言,而是 ...
- JAVA面向对象-----抽象类注意细节
抽象类可以没有抽象方法(java.awt.*的类就是这样子操作的). 抽象类可以继承普通类与抽象类. 抽象类不能直接使用类名创建实例,但是有构造方法,构造方法是让子类进行初始化. 抽象类一定有构造方法 ...
- char能表示(-128~127)
char 的取值范围是 -128 ~127 注:数0的补码表示是唯一的: +0的补码=+0的反码=+0的原码=00000000 -0的补码=11111111+1=00000000(mod 2的8次方) ...
- 【并发编程】AIDL关键字
oneway Oneway interfaces In early betas, the Android IPC was strictly synchronous. This means that s ...
- 剑指Offer——栈的java实现和栈的应用举例
剑指Offer--栈的java实现和栈的应用举例 栈是一种先进后出的数据结构, 栈的实现如下: 首先定义了栈需要实现的接口: public interface MyStack<T> { / ...