Description of problem: java.util.Scanner.nextFloat() raises java.util.InputMismatchException while reading a floating point number. Please notice that I could workaround this by using Float.parseFloat(myScanner.next()) I'm attaching a simple test program and a test text file: try to run it with both JDK and OpenJDK and you'll see the difference. Version-Release number of selected component (if applicable): 1.6.0.0-0.15.b09.fc9 How reproducible: Always Steps to Reproduce: 1. Just create a new Scanner object with a string containing only a floating point number 2. it will compile fine as exspected 3. but it will raise the InputMismatchException Additional info: I still didn't test the other methods of java.util.Scanner so I can't say whether they will work or not.
Created attachment 309918 [details] the test program sources
Created attachment 309919 [details] text file i used to test the method
java-1.6.0-openjdk-1.6.0.0-0.15.b09.fc9.i386 $ java Test test.txt 0.123 $ /opt/jdk1.6.0_03/bin/java Test testtt 0.123 $ java -version java version "1.6.0" OpenJDK Runtime Environment (build 1.6.0-b09) OpenJDK Server VM (build 1.6.0-b09, mixed mode)
testtt and test.txt are identical to the text file you attached
Lillian: I am wondering whether you tried this on PowerPC? gbenson once pointed me to an issue very similar to this, that was an explanation for a problem I had on ppc. It was occuring with an early version of GNU Classpath IIRC.
I tried to reinstall all the packages but sorry, it still doesnt work for me. this is the output i get by running the test program: $ java Test test.txt java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:857) at java.util.Scanner.next(Scanner.java:1478) at java.util.Scanner.nextFloat(Scanner.java:2336) at Test.main(Test.java:28) Scanner.nextFloat() is screwed... let's try something else. 0.123 That's really weird because it looks like nextFloat() calls next() anyway. Oh anyway I'm not on a PowerPC, just an Aspire 5630
I tested this on an i386, I will test it on x86_64 as well.
works on x86_64 $ java Test attachment.cgi 0.123 $ java -version java version "1.6.0" OpenJDK Runtime Environment (build 1.6.0-b09) OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)