こんにちは。StringWriter を使用して、新しいファイルをネットワーク フォルダーに書き込みたいと考えています。これを行う方法について、以下のコードを使用して誰かに例を教えてもらえますか? StringWriter クラスを扱うのは初めてです。
public static final void newOutput(Document xml) throws Exception {
Transformer tf = TransformerFactory.newInstance().newTransformer();
tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
tf.setOutputProperty(OutputKeys.INDENT, "yes");
StringWriter out = new StringWriter();
tf.transform(new DOMSource(xml), new StreamResult(out));
/*
* need to update to write to folder
*/
System.out.println(out.toString());
}
}