本文整理汇总了Java中javax.xml.transform.TransformerConfigurationException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java TransformerConfigurationException.printStackTrace方法的具体用法?Java TransformerConfigurationException.printStackTrace怎么用?Java TransformerConfigurationException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.transform.TransformerConfigurationException
的用法示例。
在下文中一共展示了TransformerConfigurationException.printStackTrace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import javax.xml.transform.TransformerConfigurationException; //导入方法依赖的package包/类
public static void save(String paramString, Document paramDocument) throws Exception {
DOMSource localDOMSource = new DOMSource(paramDocument);
File localFile1 = new File(paramString);
File localFile2 = localFile1.getParentFile();
localFile2.mkdirs();
StreamResult localStreamResult = new StreamResult(localFile1);
try {
TransformerFactory localTransformerFactory = TransformerFactory.newInstance();
Transformer localTransformer = localTransformerFactory.newTransformer();
Properties localProperties = localTransformer.getOutputProperties();
localProperties.setProperty("encoding", "UTF-8");
localProperties.setProperty("indent", "yes");
localTransformer.setOutputProperties(localProperties);
localTransformer.transform(localDOMSource, localStreamResult);
} catch (TransformerConfigurationException localTransformerConfigurationException) {
localTransformerConfigurationException.printStackTrace();
} catch (TransformerException localTransformerException) {
localTransformerException.printStackTrace();
}
}
示例2: setServiceDescriptionName
import javax.xml.transform.TransformerConfigurationException; //导入方法依赖的package包/类
/**
* Sets the service description name.
*
* @param serviceDescriptionFile the service description file
* @param serviceName the service name
*/
private void setServiceDescriptionName(File serviceDescriptionFile) {
String newServiceName = this.getSymbolicBundleName() + "." + CLASS_LOAD_SERVICE_NAME;
try {
// --- Open the XML document ------------------
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(serviceDescriptionFile);
// --- Get the XML root/component element -----
Node component = doc.getFirstChild();
NamedNodeMap componentAttr = component.getAttributes();
Node nameAttr = componentAttr.getNamedItem("name");
nameAttr.setTextContent(newServiceName);
// --- Save document in XML file --------------
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(serviceDescriptionFile);
transformer.transform(source, result);
} catch (ParserConfigurationException pcEx) {
pcEx.printStackTrace();
} catch (SAXException saxEx) {
saxEx.printStackTrace();
} catch (IOException ioEx) {
ioEx.printStackTrace();
} catch (TransformerConfigurationException tcEx) {
tcEx.printStackTrace();
} catch (TransformerException tEx) {
tEx.printStackTrace();
}
}
示例3: initalize
import javax.xml.transform.TransformerConfigurationException; //导入方法依赖的package包/类
@Override
public void initalize(WitsmlClient witsmlClient, String wellId, String wellboreId) {
try {
transformer = new WitsmlVersionTransformer();
} catch (TransformerConfigurationException e) {
e.printStackTrace();
}
this.witsmlClient = witsmlClient;
this.wellId = wellId;
this.wellboreId = wellboreId;
}