本文整理匯總了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;
}