//在字符串中寻找数字的函数
private double check(String x){ char text[]=x.toCharArray(); x.trim(); String number=""; for(int i=0;i<x.length();i++){ try{ number+=Integer.parseInt(""+text[i]); }catch (NumberFormatException e){ if(text[i]=='-'||text[i]=='.') number+=text[i]; continue; } } double result=0; try{ result=Double.parseDouble(""+number);} catch (Exception e){ result=0; } return result; }