当前位置: 技术问答>java相关
几个关于InputStream的小问题
来源: 互联网 发布时间:2015-05-20
本文导语: 1,ServletRequest.getInputStream(),中如果有与Boundary相同的字串怎么办?(虽然几率比较低) 2,BufferedInputStream中的方法mark(int readlimit),这个readlimit与BufferedInputStream本身的byte[] buff,有没有关系?readlimit这个长度的缓冲是在...
1,ServletRequest.getInputStream(),中如果有与Boundary相同的字串怎么办?(虽然几率比较低)
2,BufferedInputStream中的方法mark(int readlimit),这个readlimit与BufferedInputStream本身的byte[] buff,有没有关系?readlimit这个长度的缓冲是在mark()方法new的吗?如果是这样,如果readlimit与同一实例上一次调用mark时不同,时不时先要抛掉原来再new?
3,InputStream与OutputStream如何配合使用,主要用在何中情况下?
4,ServletRequest里的方法,如getContentType()获得的数据是来自ServletRequest.getInputStream(),还是另有别的结构?请给我讲一讲ServletRequest的数据结构。
2,BufferedInputStream中的方法mark(int readlimit),这个readlimit与BufferedInputStream本身的byte[] buff,有没有关系?readlimit这个长度的缓冲是在mark()方法new的吗?如果是这样,如果readlimit与同一实例上一次调用mark时不同,时不时先要抛掉原来再new?
3,InputStream与OutputStream如何配合使用,主要用在何中情况下?
4,ServletRequest里的方法,如getContentType()获得的数据是来自ServletRequest.getInputStream(),还是另有别的结构?请给我讲一讲ServletRequest的数据结构。
|
1.没有这种可能吧
2.不会
3.InputStream与OutputStream 的方法read,write是相应的,用在byte输入输出中
4.ServletRequest是包含客户机的请求信息的接口,此接口如何实现由jsp服务器决定的吧。
ServletRequest的数据结构:
Defines an object to provide client request information to a servlet. The servlet container creates a ServletRequest object and passes it as an argument to the servlet's service method.
Method Summary
java.lang.Object getAttribute(java.lang.String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
java.util.Enumeration getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this request.
java.lang.String getCharacterEncoding()
Returns the name of the character encoding used in the body of this request.
int getContentLength()
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
java.lang.String getContentType()
Returns the MIME type of the body of the request, or null if the type is not known.
ServletInputStream getInputStream()
Retrieves the body of the request as binary data using a ServletInputStream.
java.util.Locale getLocale()
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
java.util.Enumeration getLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.
java.lang.String getParameter(java.lang.String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist.
java.util.Enumeration getParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request.
java.lang.String[] getParameterValues(java.lang.String name)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
java.lang.String getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
java.io.BufferedReader getReader()
Retrieves the body of the request as character data using a BufferedReader.
java.lang.String getRealPath(java.lang.String path)
Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.
java.lang.String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request.
java.lang.String getRemoteHost()
Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined.
RequestDispatcher getRequestDispatcher(java.lang.String path)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
java.lang.String getScheme()
Returns the name of the scheme used to make this request, for example, http, https, or ftp.
java.lang.String getServerName()
Returns the host name of the server that received the request.
int getServerPort()
Returns the port number on which this request was received.
boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
void removeAttribute(java.lang.String name)
Removes an attribute from this request.
void setAttribute(java.lang.String name, java.lang.Object o)
Stores an attribute in this request.
2.不会
3.InputStream与OutputStream 的方法read,write是相应的,用在byte输入输出中
4.ServletRequest是包含客户机的请求信息的接口,此接口如何实现由jsp服务器决定的吧。
ServletRequest的数据结构:
Defines an object to provide client request information to a servlet. The servlet container creates a ServletRequest object and passes it as an argument to the servlet's service method.
Method Summary
java.lang.Object getAttribute(java.lang.String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
java.util.Enumeration getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this request.
java.lang.String getCharacterEncoding()
Returns the name of the character encoding used in the body of this request.
int getContentLength()
Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
java.lang.String getContentType()
Returns the MIME type of the body of the request, or null if the type is not known.
ServletInputStream getInputStream()
Retrieves the body of the request as binary data using a ServletInputStream.
java.util.Locale getLocale()
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
java.util.Enumeration getLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.
java.lang.String getParameter(java.lang.String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist.
java.util.Enumeration getParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request.
java.lang.String[] getParameterValues(java.lang.String name)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
java.lang.String getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
java.io.BufferedReader getReader()
Retrieves the body of the request as character data using a BufferedReader.
java.lang.String getRealPath(java.lang.String path)
Deprecated. As of Version 2.1 of the Java Servlet API, use ServletContext.getRealPath(java.lang.String) instead.
java.lang.String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request.
java.lang.String getRemoteHost()
Returns the fully qualified name of the client that sent the request, or the IP address of the client if the name cannot be determined.
RequestDispatcher getRequestDispatcher(java.lang.String path)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
java.lang.String getScheme()
Returns the name of the scheme used to make this request, for example, http, https, or ftp.
java.lang.String getServerName()
Returns the host name of the server that received the request.
int getServerPort()
Returns the port number on which this request was received.
boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
void removeAttribute(java.lang.String name)
Removes an attribute from this request.
void setAttribute(java.lang.String name, java.lang.Object o)
Stores an attribute in this request.
|
第4个问题:
getContentType()获得的数据是来自HTTP请求头。
里面有 "Content_Type: text/html" 字样。
getContentType()获得的数据是来自HTTP请求头。
里面有 "Content_Type: text/html" 字样。