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 ...
随机推荐
- RxJava操作符(09-算术/聚合操作&连接操作)
转载请标明出处: http://blog.csdn.net/xmxkf/article/details/51692493 本文出自:[openXu的博客] 目录: 算术聚合 Count Concat ...
- Xcode中lldb的REPL调试方法
Xcode中lldb调试器有一个repl语句,可以用来模拟swift解释器的REPL行为,即Read Eval Print Loop. 在Xcode里随意打开程序,中断入调试器.在调试控制台中输入re ...
- ThinkPHP 初探
准备 ThinkPHP下载 Eclipse-for-php 如何使用 放置位置 检验引用效果 效果 路由 调试之模板的使用 前提 生产模式 开发模式 添加完相应的路径以及模板文件后 总结 对国人开发的 ...
- [ExtJS5学习笔记]第三十四节 sencha extjs 5 grid表格之java后台导出excel
继上次使用js前端导出excel之后,还有一个主要大家比较关注的是后台实现导出excel,因为本人开发使用的java所以这里使用apache的开源项目poi进行后台excel的导出. 本文目录 本文目 ...
- Java命名和目录接口——JNDI
JNDI即Java命名和目录接口(JavaNaming and Directory Interface),它属于J2EE规范范畴,是J2EE的核心技术之一,提供了一组接口.类和关于命名空间的概念.JD ...
- Github客户端以及Git shell的使用
昨天介绍了怎么使用Git Shell来commit我们的代码,但是这都是简单的操作,我们还没有使用到Github是怎么进行版本控制的呢.所以,今天就来介绍一下,怎么来做版本控制吧. 必备材料 首先要确 ...
- 13 SQLiteOpenHelper SQLiteDatabase详解
创建数据库: 1. 创建一个类继承SQLiteOpenHelper 2. 创建继承对象 new SQLiteOpenHelper() 3. 用创建的对象获取可写或者可读的SQLiteDatabase ...
- Web开发学习之路--Springmvc+Hibernate之初体验
本来想继续学习android的,可是用到了android和服务器交互,需要实现个login的功能,苦于没有这么个环境,那就只能自己来搭建了.既然已经基本上可以玩web了,那么接下来使用web开源的框架 ...
- 网页搜索之后的APP搜索
搜索技术是互联网最核心的技术之一.但是移动互联网迅猛发展的今天,互联网产生的数据已经不是简单的网页搜索所能涵盖的了.比如微信公众号,产生了许多优质的内容,如果这些公众号仅仅将这些内容发布到微信平台,那 ...
- sql中奇怪的sum(1),sum(2),count(1),count(6),count(*):统计总数
sql的统计函数 sql统计函数有 count 统计条数,配合group用 sum 累加指定字段数值 但注意sum(1)就特殊 sum(1)等同于count(*) sum(1)统计个数,功能和coun ...