我有一个字符串:“100 0 2 3.0 100 420 5.0 280 420”
在代码中我这样做:
Scanner s = new Scanner(walls).useDelimiter(" ");
while (s.hasNext()) {
int type = s.nextInt();
int rotation = s.nextInt();
int actionsCount = s.nextInt();
float s1 = s.nextFloat(); --> crash on Sony
}
在 Smsung Galaxy SII (2.3.6) 和 Motorolla Xoom (4.1.2) 上一切正常。为什么在 Sony XPERIA Acrto s wirh Android 4.0.4 上会出现此错误?
03-01 11:05:42.436: E/AndroidRuntime(21019): java.util.InputMismatchException
03-01 11:05:42.436: E/AndroidRuntime(21019): at java.util.Scanner.next(Scanner.java:1012)
03-01 11:05:42.436: E/AndroidRuntime(21019): at java.util.Scanner.nextFloat(Scanner.java:1297)