報錯背景
Caused by: java.lang.NumberFormatException: For input string: "0.5,0.8"
報錯原因
"0.5,0.8"轉化為float類型報錯,有的時候就是會有這種誤操作,居然讓flink挂了!
解決方案
手動try catch 當報錯的時候,手動處理就夠了
public static void main(String[] args) {
String a="0.5,0.8";
float b=0;
try{
b= Float.parseFloat(a);
}catch (NumberFormatException e){
b=0;
}
System.out.println(b);
}
就不會報錯了