gpt4 book ai didi

java - 关闭StreamSource

转载 作者:行者123 更新时间:2023-12-01 12:48:26 25 4
gpt4 key购买 nike

我的网络服务上出现打开文件过多错误,只是想确保没有其他需要关闭的内容。我在 outWriter (StringWriter) 上添加了 close(),但 JavaDoc 说这没有效果。 getCachedExtractSoapBodyXslt() 获取 javax.xml.transform.Transformer 对象。

String payload;
StreamResult result=null;
StringWriter outWriter=null;
try {
// Programmatically extract the SOAP Body from message
outWriter = new StringWriter();
result = new StreamResult(outWriter);
Source src = new StreamSource(new java.io.StringReader(doc));
getCachedExtractSoapBodyXslt().transform(src, result);
StringBuffer sb = outWriter.getBuffer();
payload = sb.toString();
} catch (TransformerException e) {
throw new ComponentException("Unable to extract SOAP Body");
}
finally {
LOG.debug("Closing XSLT transformer output stream");
try {
outWriter.close();
}
catch (IOException e) {
LOG.error("Failed to close stream for SOAP message");
}
}

最佳答案

我必须将其移至它自己的变量并关闭它

new java.io.StringReader(doc)

关于java - 关闭StreamSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24456836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com