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

Problem signing jars for web applet
Automatically Updating Database Schema For Java Project's Unit Tests
Java, How to Instance HttpCookie from a String, any convenient ways?
For improving my programming skills I want to follow “learn a new language a year”. What we can learn in 2011
Java Networking Problem: java.net.ConnectException: Connection refused: connect
How to execute task and show its progress in spring web flow
Design Help! java generics in a enum factory transformer!
editing the contents of an array list
Dynamically add Textbox to Window when checkbox is checked
Java Exceptions: exception myException is never thrown in body of corresponding try statement
How to store values in MONGO DB using JAVA?
Why the image is not displayed in the imageItem?
Maven and AppServer dependency management best practice
How to delete obsolete workspace in RAD?
MySQL connection in Java problem
Java Graphics Multiple Classes

Categories

HOME
atom-editor
listview
ngrx
rsync
elm
paw-app
frameworks
gps
networkx
upload
contact
u-sql
mapserver
fortumo
dosgi
systemc
evopdf
jprofiler
jquery-ajaxq
info.plist
gitignore
objectanimator
librato
airconsole
create-table
mozilla
adobe-premiere
bitbucket-pipelines
dynamics-crm-2013
starteam
elasticsearch-plugin
particles.js
fakeiteasy
arena-simulation
total-commander
thin
skeleton-css-boilerplate
qwt
fancybox-2
elgg
drupal-6
forever
pdfclown
arrow-keys
smart-table
google-cdn
deadbolt-2
spring-android
fody
merge-conflict-resolution
testng-dataprovider
nessus
separator
intel-fortran
qdialog
pundit
riak-cs
apache-commons-fileupload
vstest.console.exe
p2
key-management
proj4js
xc16
google-style-guide
winddk
relocation
heisenbug
transcoding
cloud-connect
tws
excel-2003
eventual-consistency
random-seed
eventlistener
browser-detection
hgsubversion
custom-backend
pydot
servicehost
recent-documents
telerik-scheduler
rescale
meego
libs
virtual-functions
scripting-languages
msdev
paul-graham

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile