-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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.