new File(fileName).getName();
要么
int idx = fileName.replaceAll("\\", "/").lastIndexOf("/");return idx >= 0 ? fileName.substring(idx + 1) : fileName;请注意,第一个解决方案取决于系统。它仅考虑系统的路径分隔符。因此,如果您的代码在Unix系统上运行并接收Windows路径,则它将无法正常工作。当Internet
Explorer发送文件上传时,就是这种情况。



