
代码库
dahaibeibe
这个作者很懒,什么都没留下…
展开
-
删除行首和行尾的空格符
public String replaceBlank(String str){ Pattern pt=Pattern.compile("^\\s+|\\s+$"); Matcher mt=pt.matcher(str); str=mt.replaceAll(""); return str; }其中 ^ 表示行首,$ 表示行尾。比如^java就是以java开头,原创 2013-05-09 20:38:25 · 1514 阅读 · 0 评论 -
从txt文件中读取数据存入数组
原txt文件内容如下: “FXH-05”,“我是中国人”,“ggfhsdg发” ,“654321”,“谢谢你!”,007 # 325,1643,133,1157 131,6423,241,22122 # 325,1423,133,1857 131,1223,211,22265 编写代码处理后,变成: “FXH-05” “我是中国人” “ggfhsdg发” “6543原创 2013-05-09 21:11:20 · 7889 阅读 · 0 评论 -
可以设定小数点的位数
public static double round(double value, int scale,int roundingmode) { BigDecimal bd = new BigDecimal(value); bd = bd.setScale(scale,roundingmode); double d = bd.doubleValue(); bd = null;原创 2013-05-09 21:41:53 · 1137 阅读 · 0 评论