我試圖使用字符串生成器追加第一個文件與它的位置,然後新線第二個文件與其位置等。我該怎麼做?什麼是正確的語法?我的下面循環有什麼問題?在一個循環中使用字符串生成器和數組java
@Override
public List<FileUpload> uploadFile(MultipartFile[] files, String windowsUsername, String number) {
List<FileUpload> uploadList = new ArrayList<FileUpload>();
for (MultipartFile file : files) {
FileUpload result = itsmFileService.uploadAttachment(file, number);
uploadList.add(result);
}
String supportCallID;
supportCallID = this.getSupportCallIDForTicketNumber(number);
int i = 0;
for (FileUpload loopLocation : uploadList){
notesSection = uploadList.get(i).getLocation();
StringBuilder sb = new StringBuilder();
sb.append(notesSection);
sb.toString();
}
}
}
您的StringBuilder在哪裏? –
已更新的問題 – RA19
在'for'循環之前放置'StringBuilder sb = new StringBuilder();'。 – Berger