I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.

I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.

I am reading the file using BufferedReader, then writing the output like this:

String fileName = "C:\\M2011001582.TXT";
 BufferedReader is = new BufferedReader(new FileReader(fileName));
 int lineCount=1;
 String fileData = "";
 out.println("<table border=\"1\" ><thead>"
   + "<tr><th>  SNO </th>"
   + "<th>  Batch Number </th>"
   + "<th>  amount </th>"...</tr>);
 while((fileData = is.readLine()) != null)
 {
   out.println( "<tr>"
     + "<td>" + lineCount++ + "</td>"
     + "<td>" + fileData.substring(0,6) + "</td>" //batch no
     + "<td>" + fileData.substring(6,14) + "</td></tr>" ); //amount...
  }

The output displays 4 rows and 2 columns. How can I calculate the total amount?

View Answers









Related Tutorials/Questions & Answers:
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.  I am reading...... } The output displays 4 rows and 2 columns. How can I calculate the total
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?  import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class ReadFileExample
Advertisements
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import... to open the pdf file when i execute the jsp page...{ document.close();} %> </body> I added itextpdf jar file
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import... to open the pdf file when i execute the jsp page...{ document.close();} %> </body> I added itextpdf jar file
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import... to open the pdf file when i execute the jsp page...{ document.close();} %> </body> I added itextpdf jar file
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import... to open the pdf file when i execute the jsp page...{ document.close();} %> </body> I added itextpdf jar file
I need jsp code for how to write text field value into property file.
I need jsp code for how to write text field value into property file.  Hi , I need to set the text field value into property file using jsp code. Example : Username : Valar , I have entered the value "Valar" in the text field
Creating a File I/O using import scanner, io.* and text.*
Creating a File I/O using import scanner, io.* and text.*  open a file for reading and open another file for writing data. input file hours-int, hourly rate-double, name-string. output file name-string, hours-int, hourly rate
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
I want to display 10,000 records in a jsp page.Can I display page by page?
I want to display 10,000 records in a jsp page.Can I display page by page?  When I submit a form it says "ERROR: Query request too large. Total rows... print page by page or have say 900 records per page in a jsp? Should I have
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads the data from this .properties file and display it in table format. Ex:by using
I am getting Undefined in Text Box Very Urgent - JSP-Servlet
I am getting Undefined in Text Box Very Urgent  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your superb reply. I got the coding. But I find... the value "Undefined" in Emp ID text box which is present in the main page.. Here's
how can i display a pdf file in a jtextarea
how can i display a pdf file in a jtextarea  I need to display a pdf file in a jtextfield or in a jtextarea.Atlest i need to displat it in a jframe.I have a button and while clicking on it ,i need to choose the pdf file and need
I need Oracle connector jar file. where will i download?
I need Oracle connector jar file. where will i download?  I need Oracle connector jar file. where will i download
Do I need math for data science?
Do I need math for data science?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Do I... so that I can learn the topic "Do I need math for data science?"
What skills do I need to be a data analyst?
What skills do I need to be a data analyst?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: What skills do I need to be a data analyst? Try to provide me good
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
I have doubt in jsp file.
I have doubt in jsp file.  I have doubt in jsp file. In a jsp file, there should be two buttons. One is start and other is stop. When we click on start then only stop should be enabled. Other wise it should be disabled. When
i need the source code to generate id in jsp
i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum+1,like automatically when i click the button...as well i have several kinds
i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need for this
i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need for this   i have one txt field and one button.when i entere any test in testfield then only button should
Text File I/O - DVD.java - Java Beginners
Text File I/O - DVD.java  NEED HELP PLEASE. The application should use a text file with one value on each line of the file. Each movie would use... starts, read the data file and populate the array. When the file ends, use
a jsp code for creating a text file
a jsp code for creating a text file  Hello,i need jsp code for creating a new text file for each user, when they login in to the website for creating a new data file. So i need a jsp code for following options. when user login
Which extension i use for save hibernate file.
Which extension i use for save hibernate file.   Please give me answer that which extension i use for save the hibernate file and how i run that file as well as complie that file.   hi friend, Naming convention
I need to display parts of my own website on another website in an iframe
I need to display parts of my own website on another website in an iframe  I need to display parts of my own website on another website in an iframe. please refer me how do i do
hello there i need help
hello there i need help  : i need to do a program like... i am a beginner, and aside from that i am really eager to learn java please help me with the codes and please explain to me how it works. i only need to use
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
Jsp error when i run this a jsp file
Jsp error when i run this a jsp file  hi I got this error when i run the jsp file in IDE and outside also please help me java.lang.NullPointerException org.apache.jsp.insertjsp.jspInit(insert_jsp.java:22
i need help - Development process
()); } } } it is printing the result of ping in to a file,but if i want to maintain two files in which one file will be for the reply arrived and the other...i need help  hello, i need help regarding this program. public
i need project
i need project  can u send online shoppin project 2 my mailid.   Please visit the following links: Struts2 Shopping cart JSP-Servlet Shopping cart
File I/O
File I/O  i am trying to read and write a 54mb text file from one directory to another. I managed to do it perfectly using the examples i was given... question is, is their away i can read and write in the shortes time possible(in seconds
Do I need a Masters/PhD to become a data scientist?
Do I need a Masters/PhD to become a data scientist?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Do I need a Masters/PhD to become a data scientist? Try to provide
display all words containing the letter which i gave as input...
display all words containing the letter which i gave as input...  If i enter any character,it have to display the names which having that character..write a program using java example(output) Enter any character: a Names: Abi
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
File I/O
File I/O  i am trying to read and write a file. my program works perfectly i am using PrintWriter and BufferedReader. but my problem is that when... like this input file blahblah i am a computer i am running windows i am
i am getting the problem when i am downloading the pdf file from oracle 10g database - Struts
i am getting the problem when i am downloading the pdf file from oracle 10g database  if i created the pdf file from pdf machine,it is storing into datbase and download the pdf file from database. but when i created the pdf file
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer... (for n=0) for example, 5!=5.4.3.2.1, which is 120 a) Write an application...=input.nextInt(); long num=m; for(int i=m;i>1;i
How can i read a file from nth line onwards in java
How can i read a file from nth line onwards in java  Hi, I need to read a file content from its nth line onwards till end. How can i implement it in java. Regards, Chinnu
File I/O
File I/O  greetings i was running into a problem. is their a way to read multiple files from one and write the in a different directory one by one...(); File[] files = file.listFiles(filter); for (int i = 0; i <
How do I change the while loop in this code to the range with range list style display page for a resultSet() in jsp?
How do I change the while loop in this code to the range with range list style display page for a resultSet() in jsp?  this is count record code <%@ page language="java" import="java.sql.*" %> <html> <head>
How I Upload File and Store that file name in Database using JSP
How I Upload File and Store that file name in Database using JSP  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail
I am not able to display the selected value of my combobox
I am not able to display the selected value of my combobox   <... units order by unitcode"; $rsrcResult = mysql_query($strQuery); $i=1..._assoc($rsrcResult)) { $strA = $arrayRow[$i]; $strB = $arrayRow
How do I read a large file quickly in Java?
How do I read a large file quickly in Java?  Hi, I my project I have to read vendor feed which comes in text file. Size of the file is usually in 1-2 GB in size. What is the best way to read the file efficiently? How do I read
i want to do a project using jsp and servlet....What are all the materials i need to study
i want to do a project using jsp and servlet....What are all the materials i need to study   i want to do a project using jsp and servlet....What are all the materials i need to study ?   Please visit the following
i need program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
I need Spring 2.5 example.
I need Spring 2.5 example.  Hello, I am looking forward to learn Spring framework and hence I need Spring 2.5 and Spring 3.0 example.. Thanks
File I/O
File I/O  i have a problem i am trying to print on a new line every time i reach a certain condition "if(line.startsWith("Creating"))" i want... = file.listFiles();//listFiles all file in inpath dir for (int i = 0; i <
File I/O
File I/O  i am trying to write a program that reads a text file... the text file then read it and write it into as a comma delimitade file. i have... with "tAC" and ends with "->0|0|6" as you shall see in the text file i have
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.  I am using postgresql-8.4.4-1... netbeans-6.1-ml-windows.How can I set up connection to database? Please help me
Which java can i download?
it, it's display : cartdrige no found, and when i click "ok", It was dispalay a window, which want me to insert this "Cartdrige". But no file was open, what can i...Which java can i download?  Hello, i'm a beginner on java. Which

Ads