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 ...
随机推荐
- Python descriptor
class A: def __init__(self, name): self.name = name def __get__(self, ins, cls): print('call get') i ...
- Redis 学习笔记3:Jedis 连接虚拟机下的Redis 服务
Jedis 是 Redis 官方首选的 Java 客户端开发包. 虚拟机的IP地址是192.168.8.88. Jedis代码是放在windows上的,启动虚拟机上的Redis服务之后,用Jedis连 ...
- Struts 2 之类型转换器
Struts2自定义类型转换器分为局部类型转换器和全局类型转换器 (1)局部类型转换器 如果页面传来一个参数reg.action?birthday=2010-11-12到后台action,然后属性用d ...
- 【UML 建模】在线UML建模工具 ProcessOn 使用详解
总结 : -- 推荐理由 : 最近从 Windows 操作系统 转到 MAC 上, 正在看设计模式 和 重构, 找不到好用的 UML 工具, 因此在网上找了一款可以在线使用的 UML 工具, 用起来发 ...
- gradle编译出错:Execution failed for task ':app:compileTestDebugJava'.
今天更新了android studio,从0.5.3升级到0.6.1版本,结果在IDE中编译时没有问题,但是在命令行时编译就会出现以下错误: :app:compileTestDebugJava FAI ...
- Linux Debugging(一): 使用反汇编理解C++程序函数调用栈
拿到CoreDump后,如果看到的地址都是????,那么基本上可以确定,程序的栈被破坏掉了.GDB也是使用函数的调用栈去还原"事故现场"的.因此理解函数调用栈,是使用GDB进行现场 ...
- Linux多线程实践(9) --简单线程池的设计与实现
线程池的技术背景 在面向对象编程中,创建和销毁对象是很费时间的,因为创建一个对象要获取内存资源或者其它更多资源.在Java中更是如此,虚拟机将试图跟踪每一个对象,以便能够在对象销毁后进行垃圾回收.所以 ...
- JAVA之旅(十一)——RuntimeException,异常的总结,Package,jar包,多线程概述
JAVA之旅(十一)--RuntimeException,异常的总结,Package,jar包,多程序概述 继续JAVA之旅 一.RuntimeException 在Exception种有一个特殊的子 ...
- “基于数据仓库的广东省高速公路一张网过渡期通行数据及异常分析系统"已被《计算机时代》录用
今天收到<计算机时代>编辑部寄来的稿件录用通知,本人撰写的论文"基于数据仓库的广东省高速公路一张网过渡期通行数据及异常分析系统",已被<计算机时代>录 ...
- JVM学习笔记 -- 从一段几乎所有人代码都会犯错的代码开始
废话不多说 看看这段代码.告诉我结果: import java.io.*; class Test { public static Test t = new Test(); public Test(){ ...