title: write csv file line by line using string in java
body: <p>I had a modify my original csv. now I want modified csv file whether it is generate new csv file or updated on it ...how could it possible?
  I had a extract a single column values of csv and incremented by 1. now I want csv file with modified data. how can I write file. </p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import java.io.FileWriter;
  import java.io.*;
     public class Main {
  
      public static void main(String[] args) throws IOException {
  
          String filename ="bank-full.csv";
  
          File file= new File(filename);        
          try {           
             Scanner inputStream = new Scanner(file);
             inputStream.next();           
               while(inputStream.hasNext())
              {
  
                  String data= inputStream.next();                 
                  String[] values = data.split(";");
                  double balance= Double.parseDouble(values[11]);
                  balance=balance+1;                       
  
                  values[11] = String.valueOf(balance);
  
  // iterate through the values and build a string out of them
                  StringBuilder sb = new StringBuilder();
                  for (int i = 0; i &lt; values.length; i++) {
                      sb.append(values[i]);
                      if (i &lt; values.length - 1) {
                          sb.append(";");
                      }
                  }
                  // get the new string
                  String newData = sb.toString();
  
                    BufferedWriter writer = null;
  try
  {
      writer = new BufferedWriter( new FileWriter( "bank-full.csv"));
      writer.write( newData);
  
  }
  catch ( IOException e)
  {
  }
  finally
  {
      try
      {
          if ( writer != null)
          writer.close( );
      }
      catch ( IOException e)
      {
      }
  }
          System.out.println(newData);
              }           
                  inputStream.close();
          } catch (FileNotFoundException ex) {
              Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
          }        
               }
  </code></pre>