java - Reading doubles from a .txt file -


i'm trying read .txt file has line of 3 elements, first being string such "tri" , next 2 doubles 2.3 , 4.2. problem is, keep getting compiler error when try read next double. if can me out appreciate it. problematic code:

            if(order.equals("printall"))             {                 printall();                 if(textreader.hasnext())                 {                     order = textreader.next();                     if(textreader.hasnextdouble())                     {                         dimension1 = textreader.nextdouble();                         dimension2 = textreader.nextdouble();  <---**this line**                     }                 }             } 

the line pointed @ keeps giving me error:

exception in thread "main" java.util.inputmismatchexception @ java.util.scanner.throwfor(unknown source) @ java.util.scanner.next(unknown source) @ java.util.scanner.nextdouble(unknown source) @ arraydrawer.main(arraydrawer.java:88) 

line 88 being line pointed to. sorry if it's vague, post more of code if need be. appreciated.

input program:

rec 4.2 4.0 tri 4.9 9.3 tri 2.1 9.9 compareaall printall  del 4.9 printall 

with input, program reading final "printall", "del" order number, "4.9" double, tries use nextdouble read final "printall" , fails. order "del" should followed 2 doubles.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -