字符串截取 存到list中 使用base转换文件 存储可能会用到
public void demo() { String str = "ABCDEFGfdsdgdgdgdH1f"; List<String> list = new ArrayList<String>(); String streee = ""; int len = str.length(); int sub = 3; if (len % sub != 0) { for (int i = 0; i < str.length() - (len % sub); i += 3) { streee = str.substring(i, i + 3); list.add(streee); } String tpm = str.substring(str.length() - (len % sub), str.length()); list.add(tpm); } else { for (int i = 0; i < str.length(); i += 3) { streee = str.substring(i, i + 3); list.add(streee); } } for (String arr : list) { System.err.println(arr); } }
时间: 2024-10-13 13:04:06