Retrieve Data from CSV file in JSP
CSV file : A CSV file is commonly known as a Comma Delimited File or a Character Separated File. It is a text file that has a specific format which allows saving of text in organized manner. This format known as a flat table, is very simple. Each row contains one record of information. The character used to distinguish each piece of data within each record is most commonly used a comma ",".
"myfile.csv" in the c:\csv folder
Create a Page ("ReadCsvFile.jsp") to retrieve the data from CSV file "myfile.csv".
|<%@ page import="java.io.*"%>
String fName = "c:\\csv\\myfile.csv";
FileInputStream fis = new FileInputStream(fName);
DataInputStream myInput = new DataInputStream(fis);
while ((thisLine = myInput.readLine()) != null)
String strar = thisLine.split(",");
out.print(" " +strar[j]+ " ");
out.print(" <b>" +strar[j]+ "</b> ");
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: September 26, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles