title: How to download csv file without writing it using OpenCsv
body: <p>I am using OpenCsv API and now i am stuck in some problem.Here's my code</p>
  
  <pre><code>protected void processRequest(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          response.setContentType("text/html;charset=UTF-8");
          PrintWriter out = response.getWriter();
  
          try {
              List&lt;UserRegData&gt; userRegDataList = new ArrayList&lt;UserRegData&gt;();
              HttpSession session = request.getSession();
              userRegDataList = (List&lt;UserRegData&gt;) session.getAttribute("referralData");
              List&lt;String[]&gt; dataToWrite = new ArrayList&lt;String[]&gt;();
              String csv = "E:\\carewave_backup\\csv\\UserReferral.csv";
              CSVWriter writer = new CSVWriter(new FileWriter(csv));
  
              for (UserRegData obj : userRegDataList) {
                  dataToWrite.add(new String[]{obj.getReferred_by_name(), obj.getInvitee_name(), obj.getInvitee_email(), obj.getInvitee_date(), obj.getIsInviteeRegistered(), obj.getDate_of_invitee_registered()});
              }
              writer.writeAll(dataToWrite);
              writer.close();
          } catch (Exception ex) {
              ex.printStackTrace();
          } finally {
              out.close();
          }
      }
  </code></pre>
  
  <p>This servlet basically retrieves list from session and writes it to csv file.This servlet is triggered after user clicks download csv button.Now what i need is, browser should give a download dialogue.Is there anyway to download it in csv format without writing it to file first?.</p>