public static class ContentStreamBase.StringStream extends ContentStreamBase
ContentStream from a StringContentStreamBase.ByteArrayStream, ContentStreamBase.FileStream, ContentStreamBase.StringStream, ContentStreamBase.URLStreamcontentType, DEFAULT_CHARSET, name, size, sourceInfo| 构造器和说明 |
|---|
StringStream(String str) |
StringStream(String str,
String contentType) |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
detect(String str) |
Reader |
getReader()
If an charset is defined (by the contentType) use that, otherwise
use a StringReader
|
InputStream |
getStream()
Get an open stream.
|
attemptToDetermineContentType, create, getCharsetFromContentType, getContentType, getName, getSize, getSourceInfo, setContentType, setName, setSize, setSourceInfopublic StringStream(String str)
public InputStream getStream() throws IOException
ContentStream
InputStream stream = stream.getStream();
try {
// use the stream...
}
finally {
IOUtils.closeQuietly(stream);
}
Only the first call to getStream() or getReader()
is guaranteed to work. The runtime behavior for additional calls is undefined.
Note: you must call getStream() or getReader() before
the attributes (name, contentType, etc) are guaranteed to be set. Streams may be
lazy loaded only when this method is called.IOExceptionpublic Reader getReader() throws IOException
getReader 在接口中 ContentStreamgetReader 在类中 ContentStreamBaseIOExceptionCopyright © 2006–2022 The Apache Software Foundation. All rights reserved.