public class StreamResult 
 extends Object implements Result
| java.lang.Object | |
| ↳ | javax.xml.transform.stream.StreamResult | 
充当转换结果的持有者,可能是XML,纯文本,HTML或其他形式的标记。
| Constants | |
|---|---|
| String | FEATURE如果  | 
| Inherited constants | 
|---|
|  From interface  javax.xml.transform.Result  | 
| Public constructors | |
|---|---|
|  StreamResult() 零参数默认构造函数。 | |
|  StreamResult(OutputStream outputStream) 从字节流构造StreamResult。 | |
|  StreamResult(Writer writer) 从字符流构造StreamResult。 | |
|  StreamResult(String systemId) 从URL构建StreamResult。 | |
|  StreamResult(File f) 从文件构造StreamResult。 | |
| Public methods | |
|---|---|
|  OutputStream |  getOutputStream() 获取使用setOutputStream设置的字节流。 | 
|  String |  getSystemId() 获取使用setSystemId设置的系统标识符。 | 
|  Writer |  getWriter() 获取用setWriter设置的字符流。 | 
|  void |  setOutputStream(OutputStream outputStream) 设置要写入的ByteStream。 | 
|  void |  setSystemId(String systemId) 设置可能与字节或字符流关联使用的systemID,或者,如果两者均未设置,则将此值用作可写的URI(可能是文件名)。 | 
|  void |  setSystemId(File f) 从  | 
|  void |  setWriter(Writer writer) 设置要接收结果的作者。 | 
| Inherited methods | |
|---|---|
|  From class  java.lang.Object  | |
|  From interface  javax.xml.transform.Result  | |
String FEATURE
如果 getFeature(String)在将此值作为参数传递时返回true,则Transformer支持此类型的Result输出。
常量值:“http://javax.xml.transform.stream.StreamResult/feature”
StreamResult (OutputStream outputStream)
从字节流构造StreamResult。 通常,应该使用流而不是读取器,以便变换器可以使用包含在转换指令中的指令来控制编码。
| Parameters | |
|---|---|
| outputStream | OutputStream: A valid OutputStream reference. | 
StreamResult (Writer writer)
从字符流构造StreamResult。 通常,应该使用流而不是读取器,以便变换器可以使用包含在转换指令中的指令来控制编码。 但是,有时候写入字符流是有用的,例如使用StringWriter时。
| Parameters | |
|---|---|
| writer | Writer: A valid Writer reference. | 
StreamResult (String systemId)
从URL构建StreamResult。
| Parameters | |
|---|---|
| systemId | String: Must be a String that conforms to the URI syntax. | 
StreamResult (File f)
从文件构造StreamResult。
| Parameters | |
|---|---|
| f | File: Must a non-null File reference. | 
OutputStream getOutputStream ()
获取使用setOutputStream设置的字节流。
| Returns | |
|---|---|
| OutputStream | The byte stream that was set with setOutputStream, or null if setOutputStream or the ByteStream constructor was not called. | 
String getSystemId ()
获取使用setSystemId设置的系统标识符。
| Returns | |
|---|---|
| String | The system identifier that was set with setSystemId, or null if setSystemId was not called. | 
Writer getWriter ()
获取用setWriter设置的字符流。
| Returns | |
|---|---|
| Writer | The character stream that was set with setWriter, or null if setWriter or the Writer constructor was not called. | 
void setOutputStream (OutputStream outputStream)
设置要写入的ByteStream。 通常,应该使用流而不是读取器,以便变换器可以使用包含在转换指令中的指令来控制编码。
| Parameters | |
|---|---|
| outputStream | OutputStream: A valid OutputStream reference. | 
void setSystemId (String systemId)
设置可能与字节或字符流关联使用的systemID,或者,如果两者均未设置,则将此值用作可写的URI(可能是文件名)。
| Parameters | |
|---|---|
| systemId | String: The system identifier as a URI string. | 
void setSystemId (File f)
从 File参考中设置系统ID。
请注意使用toURI()和toURL() 。 如果可能,优选使用toURI() 。 为了让JAXP 1.3对J2SE 1.3运行, toURL()如果使用NoSuchMethodException被使用的尝试抛出toURI() 。
| Parameters | |
|---|---|
| f | File: Must a non-null File reference. | 
void setWriter (Writer writer)
设置要接收结果的作者。 通常,应该使用流而不是写入器,以便变换器可以使用包含在转换指令中的指令来控制编码。 但是,有时候写入作者是有用的,例如使用StringWriter时。
| Parameters | |
|---|---|
| writer | Writer: A valid Writer reference. |