private String convertObjectToXmlStr(Object object) throws Exception {
StringWriter stringWriter = new StringWriter();
JAXBContext jaxbContextRequest;
try {
jaxbContextRequest = JAXBContext.newInstance(object.getClass());
Marshaller jaxbMarshaller = jaxbContextRequest.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(object, stringWriter);
String xml = stringWriter.toString();
return xml;
} catch (JAXBException e) {
logger.error("convertObjectToXmlStr faild. cause : " + e.getMessage());
}
}
'java' 카테고리의 다른 글
객체를 인자로 보내서 값을 설정하는것 (0) | 2014.03.18 |
---|---|
Java GCM 샘플 코드 (0) | 2014.03.17 |
GCM MismatchSenderId (0) | 2014.03.12 |
xmpp sasl authentication digest-md5 failed not-authorized (0) | 2014.03.04 |
자바 정규표현식 필터링 Pattern 사용법 예시 (0) | 2014.02.04 |