java


java myeclipse. i am trying to load data from csv file and add all the numbers in 10 column


scanning the csv document using scanner class
i get error at int number= Integer.parseInt(values[9]);
ERROR:
Exception in thread "main" java.lang.NumberFormatException: For input string: "207""
at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at netex.netEx.main(netEx.java:24)
package example;
import java.util.*;
import java.io.*;
public class myex
{
public static void main(String[] args)
{
String fileName= "pedestrain.csv";
File file = new File(fileName);
Scanner inputStream;
try {
inputStream = new Scanner(file);
inputStream.next();
double sum=0;
double numberOfEntries=0;
while (inputStream.hasNext())
{
String data= inputStream.next();
String values []= data.split(",");
int number= Integer.parseInt(values[9]);
sum = sum + number;
numberOfEntries++;
}
inputStream.close();
System.out.println(sum);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
What's written in the File you want to read?
It seems like that is no string that's only made out of numbers.

Related Links

How to create backfocus on edittext
Error when accesing MySQL database remotely using public IP
TextView.setText(int) causes app to crash
Override already configured WebMvcAdapter in Spring
Java Fx custom image as scatter chart data point
Regex match single word
How to find JSON attribute value using another attribute value in java
How to add custom annotations to JSON schema?
How to Merge two pptx files having charts and tables using java api?
How to split with multiple delimiters
Is communication between to Java processes still within Microservices?
How Do I Create/Configure Spring Actuator for Multiple Datasources?
Starting appium server through Java
Jaxb String from XML
How to convert a Spring application WAR to stand-alone JAR?
Listing all instances of inherited class with child's attributes Java & Hibernate

Categories

HOME
gitlab
tesseract
spagobi
getelementsbytagname
setup-deployment
spring-jdbc
swagger-ui
android-youtube-api
virtualization
modx-revolution
n-gram
windows-phone-7
jsprit
progressive-web-apps
graphlab
angular-ui
database-replication
kryo
scriptcs
sox
mustache.php
user-interaction
social-media
fluentvalidation
typo3-6.2.x
compatibility
lightswitch-2013
exuberant-ctags
framemaker
azure-sql-database
xmlreader
mapbox-gl
mmenu
ios5
scaffold
libraries
serverside-rendering
android-browser
starteam
galen
pdf-reactor
heightmap
scorm
logfiles
scrollable
revapi
knockout-components
windows-iot-core-10
spring-cache
color-profile
objective-c-swift-bridge
firmata
deadbolt-2
storekit
gridview-sorting
essence
livequery
ptrace
cloudbees
phpcas
qtableview
ora-00900
intellij-14
libressl
processmodel
formatjs
pick
html-helper
googlemock
jubula
reactfx
hippomocks
picturefill
didselectrowatindexpath
flexmojos
cdc
blending
chronoforms
xamlparseexception
javaspaces
custom-backend
fireworks
infobox
tomcat-valve
appender
yui-datatable
html-input
blitz++
swing-app-framework
boost-smart-ptr
msdev
mdac

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App