當前位置: 首頁>>代碼示例>>Java>>正文


Java ParserConfigurationException.printStackTrace方法代碼示例

本文整理匯總了Java中javax.xml.parsers.ParserConfigurationException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java ParserConfigurationException.printStackTrace方法的具體用法?Java ParserConfigurationException.printStackTrace怎麽用?Java ParserConfigurationException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.parsers.ParserConfigurationException的用法示例。


在下文中一共展示了ParserConfigurationException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: load

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
private static Document load(InputStream in) throws IOException {

        Document document = null;

        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            document = db.parse(in);
        } catch (ParserConfigurationException parserConfigurationException) {
            parserConfigurationException.printStackTrace();
            Assert.fail(parserConfigurationException.toString());
        } catch (SAXException saxException) {
            saxException.printStackTrace();
            Assert.fail(saxException.toString());
        }

        return document;
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:TransformerFactoryTest.java

示例2: testAttributeCaching

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
@Test
public void testAttributeCaching() {
    File xmlFile = new File(getClass().getResource("Bug6879614.xml").getFile());
    DocumentBuilderFactory _documentBuilderFactory = DocumentBuilderFactory.newInstance();
    _documentBuilderFactory.setValidating(false);
    _documentBuilderFactory.setIgnoringComments(true);
    _documentBuilderFactory.setIgnoringElementContentWhitespace(true);
    _documentBuilderFactory.setCoalescing(true);
    _documentBuilderFactory.setExpandEntityReferences(true);
    _documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder _documentBuilder = null;
    try {
        _documentBuilder = _documentBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    }

    Document xmlDoc = null;
    try {
        xmlDoc = _documentBuilder.parse(xmlFile);
        if (xmlDoc == null) {
            System.out.println("Hello!!!, there is a problem here");
        } else {
            System.out.println("Good, the parsing went through fine.");
        }
    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:Bug6879614Test.java

示例3: export

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
public void export(File file) {
	try {
		// Create the GraphML Document
		docFactory = DocumentBuilderFactory.newInstance();
		docBuilder = docFactory.newDocumentBuilder();
		doc = docBuilder.newDocument();

		// Export the data
		exportData();

		// Save data as GraphML file
		Transformer transformer = TransformerFactory.newInstance()
				.newTransformer();
		DOMSource source = new DOMSource(doc);
		StreamResult result = new StreamResult(file);
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
		transformer.transform(source, result);

	} catch (TransformerException te) {
		te.printStackTrace();
	} catch (ParserConfigurationException pce) {
		pce.printStackTrace();
	}
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:26,代碼來源:GraphMLExporter.java

示例4: parseCartList

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
private void parseCartList(String xml){
	cartList = new ArrayList<String>();
	//get the factory
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	try {
		DocumentBuilder db = dbf.newDocumentBuilder();
		domCL = db.parse(new InputSource(new StringReader(xml)));
		domCL.getDocumentElement().normalize();
		
		NodeList nList = domCL.getElementsByTagName("item");
	    for (int temp = 0; temp < nList.getLength(); temp++) {
	        Node nNode = nList.item(temp);
	        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
	        	Element eElement = (Element) nNode; 
	        	//put cart items in list
	        	String accum = ""+eElement.getElementsByTagName("type").item(0).getTextContent() + " / " +
	        			eElement.getElementsByTagName("make").item(0).getTextContent() + " / " +
	        			eElement.getElementsByTagName("model").item(0).getTextContent()+ " / " +
	        			eElement.getElementsByTagName("price").item(0).getTextContent(); 
	        	cartList.add(accum);
	         }
	    }
	    //catch total price and item returned from server
	    totalPrice=domCL.getElementsByTagName("totalcost").item(0).getTextContent();
	    totalItem=domCL.getElementsByTagName("totalitem").item(0).getTextContent();
	    
	}catch(ParserConfigurationException pce) {			pce.printStackTrace();
	}catch(SAXException se) {							se.printStackTrace();
	}catch(IOException ioe) {							ioe.printStackTrace();
	}catch (Exception e){								e.printStackTrace();
	}
}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:33,代碼來源:MyClientRest.java

示例5: parseUserActionResponse

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
private void parseUserActionResponse(String xml){
	messageList = new ArrayList<String>();
	//get the factory
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	try {
		DocumentBuilder db = dbf.newDocumentBuilder();
		domARB = db.parse(new InputSource(new StringReader(xml)));
		domARB.getDocumentElement().normalize();
		NodeList nList = domARB.getElementsByTagName("messagetouser");
		messageList.clear();
		//put all message from server in a list
	    for (int temp = 0; temp < nList.getLength(); temp++) {
	        Node nNode = nList.item(temp);
	        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
	        	Element eElement = (Element) nNode; 
	        	messageList.add(eElement.getTextContent());
	        }
	    }
	    //catch total items returned from server
	    totalItem=domARB.getElementsByTagName("totalitem").item(0).getTextContent();
	    
	}catch(ParserConfigurationException pce) {			pce.printStackTrace();
	}catch(SAXException se) {							se.printStackTrace();
	}catch(IOException ioe) {							ioe.printStackTrace();
	}catch (Exception e){								e.printStackTrace();
	}
}
 
開發者ID:anirban99,項目名稱:Shopping-Cart-using-Web-Services,代碼行數:28,代碼來源:MyClientSOAP.java

示例6: createDOM

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
 * Creates a DOM (Document Object Model) <code>Document<code>.
 */
private void createDOM() {
	try {
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		DocumentBuilder builder = factory.newDocumentBuilder();

		//data is a Document
		data = builder.newDocument();

		Element root = data.createElement("measure");

		root.setAttribute("name", name);
		root.setAttribute("meanValue", "null");
		root.setAttribute("upperBound", "null");
		root.setAttribute("lowerBound", "null");
		root.setAttribute("progress", Double.toString(getSamplesAnalyzedPercentage()));
		root.setAttribute("data", "null");
		root.setAttribute("finished", "false");
		root.setAttribute("discarded", "0");
		root.setAttribute("precision", Double.toString(analyzer.getPrecision()));
		root.setAttribute("maxSamples", Double.toString(getMaxSamples()));

		data.appendChild(root);

	} catch (FactoryConfigurationError factoryConfigurationError) {
		factoryConfigurationError.printStackTrace();
	} catch (ParserConfigurationException e) {
		e.printStackTrace();
	}

}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:34,代碼來源:Measure.java

示例7: setServiceDescriptionName

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的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();
	}
	
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:43,代碼來源:BundleBuilder.java

示例8: initialValue

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
@Override
protected DocumentBuilder initialValue() {
	try {
		return defaultDocumentBuilderFactory.get().newDocumentBuilder();
	} catch (ParserConfigurationException e) {
		e.printStackTrace();
		return null;
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:10,代碼來源:XMLUtils.java

示例9: getDocument

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
 * Returns the entire Document representing GUI data structure.
 * @param model data structure
 * @return complete GUI data structure in Document format
 */
public static Document getDocument(CommonModel model) {
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	DocumentBuilder docBuilder = null;
	try {
		docBuilder = dbf.newDocumentBuilder();
	} catch (ParserConfigurationException e) {
		e.printStackTrace();
		return null;
	}
	Document modelDoc = docBuilder.newDocument();
	// Writes all elements on Document
	writeGuiInfos(modelDoc, model);
	return modelDoc;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:20,代碼來源:GuiXMLWriter.java

示例10: getDocument

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
 * Returns the entire Document representing results data structure.
 * @param measure data structure
 * @return complete measures data structure in Document format
 */
public static Document getDocument(MeasureDefinition measure) {
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	DocumentBuilder docBuilder = null;
	try {
		docBuilder = dbf.newDocumentBuilder();
	} catch (ParserConfigurationException e) {
		e.printStackTrace();
		return null;
	}
	Document modelDoc = docBuilder.newDocument();
	// Writes all elements on Document
	writeResults(modelDoc, measure);
	return modelDoc;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:20,代碼來源:XMLResultsWriter.java

示例11: parseXMLFile

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
public void parseXMLFile(String url) {
	SAXParserFactory spf = SAXParserFactory.newInstance();
	try {
		Scanner sc = new Scanner(new File(url), "UTF-8");
		
		while(sc.hasNextLine())
		{
			sc.nextLine().trim().replaceFirst("^([\\W]+)<","<");
			break;
		}

	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	try {
		//get a new instance of parser
		SAXParser sp = spf.newSAXParser();

		//parse the file and also register this class for call backs
		sp.parse(url, this);


	}catch(SAXException se) {
		se.printStackTrace();
	}catch(ParserConfigurationException pce) {
		pce.printStackTrace();
	}catch (IOException ie) {
		ie.printStackTrace();
	}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:32,代碼來源:ShipControl.java

示例12: initialValue

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
protected DocumentBuilder initialValue() {
	try {
		return defaultDocumentBuilderFactory.get().newDocumentBuilder();
	} catch (ParserConfigurationException e) {
		e.printStackTrace();
		return null;
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:9,代碼來源:SchemaUtils.java

示例13: DocumentParser

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
public DocumentParser() {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }
}
 
開發者ID:laohans,項目名稱:swallow-core,代碼行數:9,代碼來源:DocumentParser.java

示例14: parse

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
private Document parse() throws IOException, SAXException{
    try{
        DocumentBuilder db = DocumentBuilderFactory.
                newInstance().
                newDocumentBuilder();
        Document doc = db.parse(url.openStream()); // will throw SAXException upon failure
        doc.normalizeDocument(); // make sure everything is lined up properly; probably not an issue
        return doc;
    }
    catch(ParserConfigurationException e) { e.printStackTrace(); return null; }
}
 
開發者ID:beesenpai,項目名稱:EVE,代碼行數:12,代碼來源:Feed.java

示例15: XML

import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
XML(Micro_Sim processing) {
    this.processing = processing;
    File file = new File(filepath);
    file.delete();

    docFactory = DocumentBuilderFactory.newInstance();
    try {
        docBuilder = docFactory.newDocumentBuilder();
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    }
}
 
開發者ID:Majiick,項目名稱:MicroSim,代碼行數:13,代碼來源:XML.java


注:本文中的javax.xml.parsers.ParserConfigurationException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。