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


Java XMLStreamException.printStackTrace方法代碼示例

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


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

示例1: startElement

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Override
public void startElement(String uri, String name, String qName,
		Attributes atts) {

	try {
		isSalary = (uri.equals(ns) && name.equals("salary"));
		writer.writeStartElement(name);
		if (!(uri.equals(lastNamespace))) {
			lastNamespace = uri;
			writer.setDefaultNamespace(uri);				
			writer.writeDefaultNamespace(uri);
		}
		for (int i = 0; i < atts.getLength(); i++) {
			writer.writeAttribute(atts.getLocalName(i), atts.getValue(i));
		}
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:20,代碼來源:Cut.java

示例2: writeRow

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
private void writeRow(final Row row, final XMLStreamWriter out, final Map<String, String> columns) {
	try {
		int rowIndex = row.getRowNum();
		out.writeStartElement("row");
		final String rowNum = String.valueOf(rowIndex);
		out.writeAttribute("row", rowNum);
		int count = 0;
		Iterator<Cell> cellIterator = row.iterator();
		while (cellIterator.hasNext()) {
			Cell cell = cellIterator.next();
			int columnIndex = cell.getColumnIndex();
			if (this.exportEmptyCells) {
				while (count < columnIndex) {
					this.writeAnyCell(rowIndex, count, null, out, columns);
					count++;
				}
			}
			this.writeCell(cell, out, columns);
			count++;
		}
		out.writeEndElement();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}

}
 
開發者ID:Stwissel,項目名稱:Excel2XML,代碼行數:27,代碼來源:E2xCmdline.java

示例3: dump

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
protected void dump(String header, Packet packet) {
    out.println("====["+name+":"+header+"]====");
    if(packet.getMessage()==null)
        out.println("(none)");
    else
        try {
            XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(out) {
                @Override
                public void close() {
                    // noop
                }
            });
            writer = createIndenter(writer);
            packet.getMessage().copy().writeTo(writer);
            writer.close();
        } catch (XMLStreamException e) {
            e.printStackTrace(out);
        }
    out.println("============");
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:DumpTube.java

示例4: testNestedNS

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Test
public void testNestedNS() throws Exception {

    final String VALID_XML = "<foo xmlns:xmli='http://www.w3.org/XML/1998/namespacei'><bar xmlns:xmli='http://www.w3.org/XML/1998/namespaceii'></bar></foo>";

    try {
        XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(VALID_XML));

        while (xsr.hasNext()) {
            xsr.next();
        }

        // expected success
    } catch (XMLStreamException e) {
        e.printStackTrace();

        Assert.fail("Wellformedness error is not expected: " + VALID_XML + ", " + e.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:DoubleXmlnsTest.java

示例5: testNestedXmlns

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Test
public void testNestedXmlns() throws Exception {

    final String VALID_XML = "<foo xmlns:xml='http://www.w3.org/XML/1998/namespace'><bar xmlns:xml='http://www.w3.org/XML/1998/namespace'></bar></foo>";

    try {
        XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(VALID_XML));

        while (xsr.hasNext()) {
            xsr.next();
        }

        // expected success
    } catch (XMLStreamException e) {
        e.printStackTrace();
        Assert.fail("Wellformedness error is not expected: " + VALID_XML + ", " + e.getMessage());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:DoubleXmlnsTest.java

示例6: testCR6419687

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
/**
 * Test: 6419687 NPE in XMLEventWriterImpl.
 */
@Test
public void testCR6419687() {

    try {
        InputStream in = getClass().getResourceAsStream("ReaderToWriterTest.wsdl");
        OutputStream out = new FileOutputStream(USER_DIR + "ReaderToWriterTest-out.xml");

        XMLEventReader reader = XML_INPUT_FACTORY.createXMLEventReader(in);
        XMLEventWriter writer = XML_OUTPUT_FACTORY.createXMLEventWriter(out, "UTF-8");
        while (reader.hasNext()) {
            XMLEvent event = reader.nextEvent();
            writer.add(event);
        }
        reader.close();
        writer.close();
    } catch (XMLStreamException xmlStreamException) {
        xmlStreamException.printStackTrace();
        Assert.fail(xmlStreamException.toString());
    } catch (FileNotFoundException fileNotFoundException) {
        fileNotFoundException.printStackTrace();
        Assert.fail(fileNotFoundException.toString());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:ReaderToWriterTest.java

示例7: startDocument

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Override
public void startDocument() throws SAXException {
	try {
		writer.writeStartDocument();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:9,代碼來源:Cut.java

示例8: endDocument

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Override
public void endDocument() throws SAXException {
	try {
		writer.writeEndDocument();
		writer.close();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}

}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:11,代碼來源:Cut.java

示例9: endElement

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Override
public void endElement(String uri, String name, String qName) {
	isSalary = false;
	try {
		writer.writeEndElement();
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:10,代碼來源:Cut.java

示例10: characters

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Override
public void characters(char[] ch, int start, int length) {
	try {
		if (isSalary) {
			String str = String.valueOf(ch, start, length);
			double salary = Double.parseDouble(str);
			writer.writeCharacters(String.valueOf(salary / 2));
		} else {
			writer.writeCharacters(String.valueOf(ch, start, length));
		}
	} catch (XMLStreamException e) {
		e.printStackTrace();
	}
}
 
開發者ID:amritbhat786,項目名稱:DocIT,代碼行數:15,代碼來源:Cut.java

示例11: addStaxNamespacePrefix

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
private void addStaxNamespacePrefix(Entry<String, String> entry, ToXmlGenerator toXmlGenerator) {
  try {
    toXmlGenerator.getStaxWriter().setPrefix(entry.getKey(), entry.getValue());
  } catch (XMLStreamException e) {
    e.printStackTrace();
  }
}
 
開發者ID:daflockinger,項目名稱:unitstack,代碼行數:8,代碼來源:ExtendedXmlMapper.java

示例12: test

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Test
public void test() {
    try {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
        for (int i = 0; i < 3; i++) {
            runReader(factory, i);
        }
    } catch (XMLStreamException xe) {
        xe.printStackTrace();
        Assert.fail(xe.getMessage());
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:SkipDTDTest.java

示例13: readPayload

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Override
public XMLStreamReader readPayload() {
    try {
        return delegate.readPayload();
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:MessageWrapper.java

示例14: setUpForNoRepair

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
private void setUpForNoRepair() {

        xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);

        // new Writer
        try {
            xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(byteArrayOutputStream);

        } catch (XMLStreamException xmlStreamException) {
            xmlStreamException.printStackTrace();
            Assert.fail(xmlStreamException.toString());
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:NamespaceTest.java

示例15: testDuplicateNSDeclaration

import javax.xml.stream.XMLStreamException; //導入方法依賴的package包/類
@Test
public void testDuplicateNSDeclaration() {

    // expect only 1 Namespace Declaration
    final String EXPECTED_OUTPUT = "<?xml version=\"1.0\" ?>" + "<ns1:foo" + " xmlns:ns1=\"http://example.com/\">" + "</ns1:foo>";

    // have XMLOutputFactory repair Namespaces
    XMLOutputFactory ofac = XMLOutputFactory.newInstance();
    ofac.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));

    // send output to a Stream
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    StreamResult sr = new StreamResult(buffer);
    XMLStreamWriter w = null;

    // write a duplicate Namespace Declaration
    try {
        w = ofac.createXMLStreamWriter(sr);
        w.writeStartDocument();
        w.writeStartElement("ns1", "foo", "http://example.com/");
        w.writeNamespace("ns1", "http://example.com/");
        w.writeNamespace("ns1", "http://example.com/");
        w.writeEndElement();
        w.writeEndDocument();
        w.close();
    } catch (XMLStreamException xmlStreamException) {
        xmlStreamException.printStackTrace();
        Assert.fail(xmlStreamException.toString());
    }

    // debugging output for humans
    System.out.println();
    System.out.println("actual:   \"" + buffer.toString() + "\"");
    System.out.println("expected: \"" + EXPECTED_OUTPUT + "\"");

    // are results as expected?
    Assert.assertEquals(EXPECTED_OUTPUT, buffer.toString());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:39,代碼來源:DuplicateNSDeclarationTest.java


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