Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:42:14+00:00 2026-06-16T16:42:14+00:00

I have Java based Spring MVC application that also uses Spring security. I am

  • 0

I have Java based Spring MVC application that also uses Spring security. I am using hibernate as an ORM tool for this web app.

Following is my requirement —

User will have ability to upload a CSV file using a web browser. The format of the CSV file is known to have following 5 fields:

userId, location, itemId, quantity, tranDate
001, NY, 00A8D5, 2, 12/31/2012
002, MN, 00A7C1, 10, 12/22/2012
.
.

like this there are about 100 rows.

I am using Super CSV in the project:

private void readWithCsvBeanReader(String CSV_FILENAME) throws Exception {

    String CSV_FILENAME = "\\\\Serv01\\Files\\QueryResult.csv";
    //String CSV_FILENAME = "C:\\Files\\QueryResult.csv";
    ICsvBeanReader beanReader = null;
    try {
        beanReader = new CsvBeanReader(new FileReader(CSV_FILENAME),
                CsvPreference.STANDARD_PREFERENCE);

        // the header elements are used to map the values to the bean (names
        // must match)
        final String[] header = beanReader.getHeader(true);
        // get Cell Processor
        final CellProcessor[] processors = getProcessors();

Here I am reading the contents of the CSV file and then using Hibernate, I am inserting it.

This works fine as I am providing the CSV path locally or on the windows share.

String CSV_FILENAME = "\\\\Serv01\\Files\\QueryResult.csv";
or via this:
String CSV_FILENAME = "C:\\Files\\QueryResult.csv"; 
  1. How can I achieve this requirement such that the CSV file path location will be provided by a button on the webpage using Spring MVC?

  2. Is it also possible to pick up the file automatically from a remote location such that I will upload the file in a FTP location and then the program can connect to the remote ftp location and process the file on a schedule?

PS: I am new to file operations and if someone can point towards some article then it will be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:42:15+00:00Added an answer on June 16, 2026 at 4:42 pm

    like this there are about 100 rows.

    Don’t bother saving the CSV as a tmp file as Spring’s Mulitpart will do that for you
    and just insert the rows directly (the request may take longer to process but given your ostensible current knowledge you can worry about optimizing that later)

    private void readWithCsvBeanReader(MultipartFile uploadedFile) throws Exception {
    
        ICsvBeanReader beanReader = null;
        try {
            beanReader = new CsvBeanReader(new InputStreamReader(uploadedFile.getInputStream()),
                    CsvPreference.STANDARD_PREFERENCE);
    
            // the header elements are used to map the values to the bean (names
            // must match)
            final String[] header = beanReader.getHeader(true);
            // get Cell Processor
            final CellProcessor[] processors = getProcessors();
    

    Make your controller something like:

    @RequestMapping(value = "/add", method=RequestMethod.POST)
    public String upload(@RequestParam("file") MultipartFile file) throws IOException {
    // call your csv parsing code.
    }
    

    Make sure you make your FORM looks something like:

    <h1>Add a File for testing</h1>
    <form method="post" action="/add" class="well form-vertical" enctype="multipart/form-data">
        <input type="file" name="file" />
        <button type="submit" class="btn">{{actionLabel}}</button>
    </form>
    

    Take notice of the enctype

    For input and output you should understand Java’s IO Decorator pattern.

    I Recommend you keep it as simple as possible so that you can learn the basics. Then worry about adding more robust solutions/libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java web application based on Spring MVC. The task is to
I have a spring mvc 3.1 application based on this tutorial . I've modified
I have a Spring MVC based Web Application with Hibernate. Following is the directory
I have been using the new feature of Spring 3.1.1 the java based configuration.
I have a Java based web-application using Java Server Faces and Facelets. I am
We have inherited an application (Java-based, running on WebLogic 10.3.5) that makes extensive use
Background: I have created a CRUD web app using a java based RAD tool
I am using java, spring mvc and apache tiles in my web application. I
I have a Java-based server side and a flex client side using Spring BlazeDS
I have currently evaluating Java based security frameworks, I am a Spring 3.0 user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.