我正在创建一个jsp页面,我在其中读取文本文件,然后以表格格式显示该数据。现在我需要计算总数。
我正在使用BufferedReader
读取文件,然后按如下方式编写输出:
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...
}
输出显示4行和2列。如何计算总金额?