title: How to replace two double quotes with a single double quote in Java String?
body: <p>I am reading a CSV file and have some values like </p>
  
  <pre><code>field 1   field 2           field 3
  1        test case1         expecting one, and \"two\", and three
  </code></pre>
  
  <p>after reading file into a <code>StringBuilder</code> and converting <code>toString()</code> I split the file content by: <code>string.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");</code>.</p>
  
  <p>On iterating the string I get these values:-</p>
  
  <pre><code>1
  test case1
  expecting one, and ""two"", and three
  </code></pre>
  
  <p>How I can I replace two double quotes with single double like this "two"</p>
  
  <p>here is my code:-</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  
  
  public class csvStringParser {
  
      /**
       * @param args
       * @throws IOException 
       */
      public static void main(String[] args) throws IOException {
          // TODO Auto-generated method stub
  
  
            String path = "E:/spc.csv";
  
              String read = readFile(path);
              System.out.println("content of the file before \" = \n"  +read);
  
  
  
  //      System.out.println("content of the file after= \n"  +read);
  
          String[] tokens = read.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
              for(int i = 0;i&lt;tokens.length;i++) {
                  String abc = tokens[i].replace("\"\"", "\"");
  
             //   if(abc.length()&gt;2){
                  if(abc.startsWith("\"") &amp;&amp; abc.endsWith("\"")){ 
                  abc = abc.substring(1, abc.length()-1);
                  }
              //  } 
  
                  System.out.println("&gt; "+abc);
              }
  
      }
  
      public static String readFile( String file ) throws IOException {
          BufferedReader reader = new BufferedReader( new FileReader (file));
          String         line = null;
          StringBuilder  stringBuilder = new StringBuilder();
          String         ls = System.getProperty("line.separator");
  
          while( ( line = reader.readLine() ) != null ) {
              stringBuilder.append( line );
              stringBuilder.append( ls );
          }
  
          return stringBuilder.toString();
      }
  
  }
  </code></pre>