开发者

How do I create an org.xml.sax.InputSource from a String?

开发者 https://www.devze.com 2023-01-27 13:06 出处:网络
I am following a 开发者_如何学JAVAguide, and it gives me the following code: InputSource inputSource = new InputSource(new FileInputStream(new File(\"/path/to/xml/file.xml\"))));

I am following a 开发者_如何学JAVAguide, and it gives me the following code:

InputSource inputSource = new InputSource(new FileInputStream(new File("/path/to/xml/file.xml"))));

What I would like to know, is how I can still create an org.xml.sax.InputSource, but instead of reading the content of a file, use a String variable that I already have.


Use a StringReader instead of a FileInputStream.

See the documentation for StringReader

example:

InputSource inputSource = new InputSource( new StringReader( myString ) );


InputSource inputSource = new InputSource(new java.io.StringReader(string)); if it is org.xml.sax.InputSource.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号