java以分号为分割符拼接字符串的技巧

String item = "E:\MR\CE\MDR\Technical Collection\88000099-Q Techinical File Index.pdf*/BC802DDC6A5349a4B1BB844292A70A78.pdf*1670891842|E:\MR\Technical Collection\\MTBF board.pdf*/A7666E3FCD244925954CA2AA0E9480E8.pdf*1890814742|";
String[] fileNames = item.getFileName().split("\\*/");
			if(fileNames != null && fileNames.length>0){
				StringBuffer newFileName = new StringBuffer();
				for (int i=0;i<fileNames.length-1;i++) {
					String[] filename = fileNames[i].split("\\\\");
					newFileName.append(filename[filename.length-1]).append(";");
				}
				String fileNameStr = newFileName.deleteCharAt(newFileName.length() - 1).toString();
				item.setFileName(fileNameStr);

			}

  

posted @ 2022-04-04 23:03  张亮java  阅读(356)  评论(0编辑  收藏  举报