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

Pb with JavaFx progressbar behavior
org.openqa.selenium.WebDriverException: chrome not reachable
GWT error while launching Development mode on Jetty or external server
Strategies of inheritance in JPA
How to perform conditional operation inside XPath?
Bukkit - other class Error
Resolve accessibility issues with tables using iText java api
Why cannot scroll ScrollView Programmatically?
Could I export model trained with h2o to Java code?
Connection Pool hanging with java multi threaded program
We Get Null when accessing the innear subject of a message/rfc822 attachment
How to create filter icon in ActionBar Toolbar programatically
How to map entities with #EmbeddedId?
Java netty rxtx pipeline blocks after writeAndFlush()
set springboot starting check redis,database,mq
How to turn A string into double

Categories

HOME
bluetooth
gitlab
coq
react-virtualized
relay
kalman-filter
setup-deployment
amazon-ecs
sharepoint-designer
rdf
angular-ui-bootstrap
wamp
flyway4
slurm
python-unittest
gnupg
google-apps-marketplace
moonmail
windows-phone-7
netflix
iolanguage
workload-scheduler
dosgi
systemc
fatal-error
windows-7-x64
interop
django-cms
plunker
errorlevel
mps
crystal-reports-2010
android-widget
info.plist
fifo
strncpy
libuv
nat
bosh
pim
framemaker
phpfreechat
elasticsearch-plugin
email-templates
fedex
nxlog
isbn
s
sencha-touch-2.3
sas-jmp
dotcover
apache-fop
qsslsocket
dds
theming
dandelion
ionicons
veracode
svmlight
statsd
directory-structure
google-perftools
pdfclown
vtigercrm
gnome-shell-extensions
xcb
removechild
android-textview
url-masking
phishing
ctest
connect-by
phpcas
browser-bugs
service-accounts
php-ci
mono-embedding
createprocessasuser
generic-programming
census
graph-api-explorer
bridge.net
inmobi
pick
nstableviewcell
qpainter
tablelayout
google-style-guide
cctv
responsive-slides
eol
article
doskey
quantlib-swig
access-rights
gridfs
runtime.exec
listings
back-stack
rabl
browser-detection
bluepill
dsn
buildr
qt-jambi
heartbeat
invite
pyinotify
oncheckedchanged
visitor-statistic
gamequery
audio-capture
adrotator
boost-smart-ptr
temporal-database
grid-system
windows-live-messenger
caching-application-block

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App