1 去除字符串中的 [ ] , " ", 逗号替换成 & 符号 public static String ReplaceString(List info) { String infoJSON = jsONObject.t
public static String ReplaceString(List info) { String infoJSON = jsONObject.toJSONString(info); String replace = infoJson.replace("]", "").replace("[", "").replace(",", "&").replace("\"", ""); return replace; }
public static String SplitString(String info, int num) { String[] temp = null; temp = info.split(","); return temp[num]; }
public static String InterceptString(String info, int i) { String substring = info.substring(0, i); return substring; }
public static String DeleString(String info, int i) { String substring = info.substring(i); return substring; }
public static String RightString(String info, int i) { String substring = info.substring(info.length() - i); return substring; }
public static String RightdeleString(String info, int i) { String substring = info.substring(0, info.length() - i); return substring; }
public static String RepinterString(String info, int i, int n) { String substring = info.substring(i, n); return substring; }
public static String AfterString(String info, String appoint) { String substring = info.substring(info.indexOf(appoint)); return substring; }
public static String AftenumString(String info, int i) { String substring = info.substring(i, info.indexOf(".", i)); return substring; }
public static String AppendString(Item info) { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("仓库: " + info.getStoreShelf().getWarehouse() + "\n"); strBuffer.append("货架: " + info.getStoreShelf().getShelf() + "\n"); strBuffer.append("架层: " + info.getStoreShelf().getLayer() + "\n"); strBuffer.append("分区: " + info.getStoreShelf().getSection() + "\n"); return strBuffer.toString(); }
public class ReplaceUtils { //字符替换 public static String ReplaceString(List info) { String infoJson = JSONObject.toJSONString(info); String replace = infoJson.replace("]", "").replace("[", "").replace(",", "&").replace("\"", ""); return replace; } //字符拆分取任意部分 public static String SplitString(String info, int num) { String[] temp = null; temp = info.split(","); return temp[num]; } //取字符串前 i 个字符 public static String InterceptString(String info, int i) { String substring = info.substring(0, i); return substring; } //取字符索引 i 之后的字符 public static String DeleString(String info, int i) { String substring = info.substring(i); return substring; } //从右边开始取 i 个字符 public static String RightString(String info, int i) { String substring = info.substring(info.length() - i); return substring; } //从右边开始去掉 i 个字符 public static String RightdeleString(String info, int i) { String substring = info.substring(0, info.length() - i); return substring; } //字符取索引 i 到 索引 n 之间的字符 (不包含 n ) public static String RepinterString(String info, int i, int n) { String substring = info.substring(i, n); return substring; } //获取指定字符之后的字符 public static String AfterString(String info, String appoint) { String substring = info.substring(info.indexOf(appoint)); return substring; } //获取从第 i 位开始,截取第一次遇到 “.” 的字符串 public static String AftenumString(String info, int i) { String substring = info.substring(i, info.indexOf(".", i)); return substring; } //字符串自定义拼接 public static String AppendString(Item info) { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("仓库: " + info.getStoreShelf().getWarehouse() + "\n"); strBuffer.append("货架: " + info.getStoreShelf().getShelf() + "\n"); strBuffer.append("架层: " + info.getStoreShelf().getLayer() + "\n"); strBuffer.append("分区: " + info.getStoreShelf().getSection() + "\n"); return strBuffer.toString(); }}
来源地址:https://blog.csdn.net/X_sunmmer/article/details/130390346
--结束END--
本文标题: Android 字符串的替换,截取,拆分,拼接
本文链接: https://lsjlt.com/news/392609.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0