Xmlを保存するInternalメソッド実装

This commit is contained in:
r-ca 2024-01-09 12:34:10 +09:00
parent a2eda32183
commit e0a344bb48
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -170,6 +170,23 @@ public class FileManagerImpl implements FileManager {
return this.setPath(resolvedPath); return this.setPath(resolvedPath);
} }
// Internal
private void saveXmlInternal(Document document, String fileName) throws IOException {
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(document);
File file = this.path.resolve(fileName).toFile();
StreamResult result = new StreamResult(file);
transformer.transform(source, result);
} catch (Exception e) {
logger.error("saveXmlInternal", e.getMessage());
throw new IOException("Failed to save xml");
}
}
@Override @Override
public FileManager saveXml(Document document, String fileName) throws IOException { public FileManager saveXml(Document document, String fileName) throws IOException {
return null; return null;