473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

java.util.InputMismatchException

oll3i
679 512MB
Expand|Select|Wrap|Line Numbers
  1. Scanner sc = new Scanner("konta//"+NumerKonta+".txt");
  2. double sr_dost = sc.nextDouble();
  3.  
why i get the error here ?
i wanna look for a double in a file
Mar 13 '07 #1
3 2118
DeMan
1,806 1GB
have you tried testing sc.hasNextDouble() to see if there is a valid token?

also (although the API is not 100% clear (the examples at the top contradict what thwe methods explain, as I read it)), you may need to get rid of "rubbish" input (the examples suggest you don't need to , but I read the method to mean that it only tests the next token, and nothing more) eg:

Expand|Select|Wrap|Line Numbers
  1. while(sc.hasMoreTokens())
  2. {
  3.   if(sc.hasNextDouble())
  4.   {
  5.     x = sc.nextDouble();
  6.   }
  7.   else
  8.   {
  9.     sc.next();
  10.   }
  11. }
  12.  
}
Mar 13 '07 #2
oll3i
679 512MB
thank u
i used
Expand|Select|Wrap|Line Numbers
  1. while(sc.hasNext())
  2. {
  3.   if(sc.hasNextDouble())
  4.   {
  5.       sr_dost = sc.nextDouble();
  6.   }
  7.   else
  8.   {
  9.     sc.next();
  10.   }
  11. }
  12.  
and it works
Mar 13 '07 #3
DeMan
1,806 1GB
Good stuff, that was lucky....
Mar 14 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: greg.knaddison | last post by:
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on...
0
by: daniel li | last post by:
I got another convert issue. This is the same project as I posted yesterday, and received a perfect response. The conversion threw a SupportClass for me and one of the data type is...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
0
by: snkssa | last post by:
Hi, I got the following error while building an application with ant. please can you give the solution or reason why it is failing? Thank you create_zip_linux: ...
0
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
3
by: Dameon99 | last post by:
Hi.. Im experiencing a weird error I dont know how to fix. I have a scanner object and whenever I use nextInt, anything above 3 causes the program to crash saying and links me to this line of the...
6
by: jri | last post by:
Hello, I got an assignement for school where I have to make a game with matches. This is what I got: import javax.swing.JOptionPane; import java.util.Scanner; public class Lucifer
1
by: jimgym1989 | last post by:
I dont get it..why is the error: Exception in thread "main" java.util.InputMismatchException this is my code /** * @(#)textFileRead.java * * * @author * @version 1.00 2008/10/17 */
3
by: kr151080 | last post by:
I need some help with a Measurement Program I Wrote.....I have this code as the main workings of my program: import java.util.*; public class Measurement{ { static Scanner console = new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.