1 2 3 4 5 6 7 8 9 10 11 12 13 |
public static String getFileName(Part filePart) { String header = filePart.getHeader("content-disposition"); for(String headerPart : header.split(";")) { if(headerPart.trim().startsWith("filename")) { return headerPart.substring(headerPart.indexOf('=') + 1).trim() .replace("\"", ""); } } return null; } |