我有一个调用 SOAP 网络服务的代码,该服务有一个附件(或多个附件),该附件是一个zip文件(或多个附件)。我只想要其中一些 zip 文件,即以“WCT_”开头的文件。
给定 AttachmentPart 变量是否有可能获取文件名?
Iterator<?> i = soapResponse.getAttachments();
Object obj = null;
while (i.hasNext()) {
System.out.println("file found");
AttachmentPart att = (AttachmentPart) i.next();
我尝试了 att.getContent().toString() 但没有打印名称。
最佳答案
尝试使用
Iterator<?> i = soapResponse.getAttachments();
Object obj = null;
while (i.hasNext()) {
System.out.println("file found");
AttachmentPart att = (AttachmentPart) i.next();
String fileName = att.getDataHandler().getName();
}
关于java - 附件部分 : how to get the name?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57314386/