title: Convert .txt file into .cvs file using java?
body: <p>I have a text file.</p>
  
  <pre><code>Date    Order ID    SKU Transaction type    Payment Type    Payment Detail  Amount  Quantity    Product Title
  
  11-May-15   171-4579244-1779543 NT52-178    Refund  Amazon fees Commission  Rs. 49.32       Masha Women's Cotton Nighty NT52-178
  
  11-May-15   171-4579244-1779543 NT52-178    Refund  Amazon fees Fixed closing fee   Rs. 11.24       Masha Women's Cotton Nighty NT52-178
  
  11-May-15   171-4579244-1779543 NT52-178    Refund  Amazon fees Shipping holdback   Rs. 3.71        Masha Women's Cotton Nighty NT52-178
  
  11-May-15   171-4579244-1779543 NT52-178    Refund  Product charges     Rs.
  -399.00 1   Masha Women's Cotton Nighty NT52-178
  </code></pre>
  
  <p>I want to convert it into a CSV file.</p>
  
  <p>I am using following code</p>
  
  <pre><code>   File file = new File("/Users/manish/Documents/New folder/report.txt");
         StringBuffer str = new StringBuffer();
         BufferedReader br = null;
  
          try
         {
              br = new BufferedReader(new FileReader(file));
              String text = null;
  
              // repeat until all lines is read
              while ((text = br.readLine()) != null)
              {
                      String splitarray[] = text.split("  ");
                      String Date = splitarray[0];
                      String Order_ID = splitarray[1]; // line 42
                      String sku = splitarray[2];
                      String Transaction_type = splitarray[3];
                      String Payment_type = splitarray[4];
                      String Payment_detail = splitarray[5];
                      String amount = splitarray[6];
                      String Quantity = splitarray[7];
                      String Product_title = splitarray[8];
                      System.out.println(Date+ " " + Order_ID);
  
              }
          } catch (FileNotFoundException e)
          {
              e.printStackTrace();
          } catch (IOException e)
          {
              e.printStackTrace();
          } finally
          {
              try
              {
                  if (br != null)
                  {
                      br.close();
                  }
              } catch (IOException e)
              {
                  e.printStackTrace();
              }
          }
  
          // show file contents here
          System.out.println(str.toString());
  </code></pre>
  
  <p>but it gives error</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
          at test_pract.TEST_pract.main(TEST_pract.java:42)
        Java Result: 1</p>
  </blockquote>