| Author |
calculations using JSP
|
Yell Srik
Ranch Hand
Joined: Mar 10, 2004
Posts: 61
|
|
hi, i am new to JSP and need ur help in doing the following. i have a text file that contains three columns: name, salary, tax with 10 rows of data. eg: name salary tax aa 1000 100 bb 2000 200 ............ using JSP/Servlets, how is it possible to extract data values from salary and tax columns and perform calculation like (salary-tax),(salary+tax) etc. thanks in advance.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
What have you tried? What has you stumped?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Nadeem Ahmad
Greenhorn
Joined: Oct 20, 2003
Posts: 28
|
|
Hi, You read the file by using File f = new File("c:\\io\\data.txt"); RandomAccessFile rf = new RandomAccessFile(f,"rw"); rf.readLine()) and then split the line with Space or any other delimeter (which is being used in the text file) using StringTokenizer Here is the example.. | is the delimeter incase of ur file it is space String username=null; try{ File f = new File("c:\\io\\data.txt"); RandomAccessFile rf = new RandomAccessFile(f,"rw"); while((username=rf.readLine())!=null){ i=0; StringTokenizer st = new StringTokenizer(username,"|"); String pr=""; while (st.hasMoreTokens()) { entry[i]=st.nextToken(); i++; } } } rf.close();
|
 |
 |
|
|
subject: calculations using JSP
|
|
|