java实战 字符串处理
Last updated on November 22, 2024 pm
🧙 Questions
☄️Ideas
public void demo() {
String fileName = "hello.ppt";
int maxLength = 200;
String prefixName = fileName.substring(0, fileName.lastIndexOf("."));
String suffixName = fileName.substring(fileName.lastIndexOf("."));
if (maxLength < suffixName.length()) {
log.info("文件名称" + suffixName.substring(0, maxLength));
}
log.info("文件名称" + prefixName.substring(0, maxLength - suffixName.length()) + suffixName);
}
🔗 Links
java实战 字符串处理
https://ispong.isxcode.com/spring/java/java实战 字符串处理/