-1

I have a maven web application in which I use JSF and spring. I want to parse a csv uploaded file with fileUploadListener. The file is uploaded, but I don't know how to get data from it and store it in database:

 <h:outputLabel value="Choose your file : *" />
                 <p:fileUpload  mode="advanced"  fileUploadListener="#{campagneMB.handleFileUpload}" update="growl"
              sizeLimit="4000000" allowTypes="/(\.|\/)(csv)$/"/>

my file has this form:

xxxx#xxxxx#xxxxx
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
elpazio
  • 697
  • 2
  • 9
  • 25

1 Answers1

0

The question seems to be related to Java more than JSF. You should read the file's content in the listener method by FileUploadEvent#getFile()#getContents() which returns byte[], then just "convert" it to String, which makes storing data in DB easier.
This link can be useful: How to read and parse CSV file in Java.

Community
  • 1
  • 1
Omar
  • 1,430
  • 1
  • 14
  • 31