我在两个单独的步骤中编组我的对象.一个添加Header,另一个添加Body.现在当我使用这段代码
marshaller.marshal(payload, writer);
//payload is Objects name and writer is StringWriter class object
Run Code Online (Sandbox Code Playgroud)
XML标记<?xml version="1.0" encoding="utf-8"?>在最终输出文件中添加两次.
[<?xml version="1.0" encoding="utf-8"?>]当我在编组正文部分时,如何才能第二次添加XML标记?
我已经使用了Marshaller界面的所有属性,但这没有帮助.
class TestExceptions {
public static void main(String[] args) throws Exception {
try {
System.out.println("try");
throw new Exception();
} catch(Exception e) {
System.out.println("catch");
throw new RuntimeException();
} finally {
System.out.println("finally");
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我尝试多次在eclipse中运行代码时的输出.我相信到目前为止,无论何时执行try/catch块的代码的最后一行(可以返回或抛出新的Exception()类型的stmt),最后都会执行块,但这里的输出不同每次?任何人都可以澄清我的假设是对还是错?
try
catch
Exception in thread "main" finally
java.lang.RuntimeException
at TestExceptions.main(TestExceptions.java:9)
Exception in thread "main" try
catch
java.lang.RuntimeException
at TestExceptions.main(TestExceptions.java:9)
finally
Run Code Online (Sandbox Code Playgroud)