![](/img/trans.png)
[英]Caused by java.lang.NumberFormatException: Invalid float: "∞"
[英]Java.lang.numberformatexception: Invalid float “0.008466”
我只是從一個php請求中獲取0.008466的值,並將其轉換為float但無法獲取。
我試圖使用numberFormat和DecimalFormat以及Float.parseFloat,但是沒有任何效果。
private void retrieveMinuteByDegreeValueFromPhp() throws IOException {
SharedPreferences prefs = mContext.getSharedPreferences(SHARED_PREFS, 0);
SharedPreferences.Editor editor = prefs.edit();
HttpClient httpclient=new DefaultHttpClient();
HttpPost httppost=new HttpPost(URL_PHP_MINUTEDEGREE);
HttpResponse response = httpclient.execute(httppost);
if ( response.getStatusLine().getStatusCode() == 200){
String str = EntityUtils.toString(response.getEntity());
float minuteByDegree = Float.valueOf(str);
if (minuteByDegree > 0){
editor.putFloat(MINUTEBYDEGREE, minuteByDegree);
editor.commit();
}
Log.d("MinuteByDegree","Minutebydegree : " + minuteByDegree);
}
else {
Log.d("MinuteByDegee","Error : " + response.getStatusLine().getStatusCode());
}
}
任何想法 ?
感謝@Thomas,字符串中隱藏了一個錯誤字符,但char Array中沒有。 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.