title: Base64: Java encoding file csv
body: <p>I wanted to generate a csv file and then attach it in an email.
  it all works very well, except that the contents of the file generate
  contains special characters as below:</p>
  
  <pre><code>¬í t ›Ã‰vÃ©nementId;DÃ©butÃ‰vÃ©nement;FinÃ‰vÃ©nement;DescriptionÃ‰vÃ©nement
  232750;20/03/201408:30;20/03/201412:30;
  233160;17/05/201412:50;17/05/201414:20;
  </code></pre>
  
  <p>below a piece of code:</p>
  
  <pre><code>String dataString= "id;date1;date2;description
   232750;20/03/201408:30;20/03/201412:30;
   233160;17/05/201412:50;17/05/201414:20;"
  
  public byte[] covertObjecttoByteArray(Object obj) throws IOException {
  byte[] bytes = null;
   ByteArrayOutputStream bytArrOutStr = null;
   ObjectOutputStream objOutStrem = null;
    try {
       bytArrOutStr = new ByteArrayOutputStream();
       objOutStrem.writeObject(obj);
       objOutStrem.flush();
        bytes = bytArrOutStr.toByteArray();
      } finally {
        if (objOutStrem != null) {
          objOutStrem.close();
          }
          if (bytArrOutStr != null) {
              bytArrOutStr.close();
          }
      }
      return bytes;
  }
  
  
   byte[] dataByte = covertObjecttoByteArray(data);
   String dataBase64 = Base64.encodeBase64String(dataByte);
  </code></pre>
  
  <p>I use this variable "dataBase64" to put the file attached in the xml structure like this</p>
  
  <pre><code>&lt;attachment FileName="Fiche.csv"&gt;
   JVBERi0xLjQKJeLjz9MKNCAwIG9iago8PC9MZW5ndGggMTIyOC9GaWx0ZXIvRmxhdGVEZWNvZGU+&amp;#13;
   PnN0cmVhbQp4nMVYTW/bRhAdQDee8uF8FTGwQA3HLVKau+QuKaCnQpEVV4VNSbZTxDk1TYCiAtxc&amp;#13;
   +gP6xzsz5JKMLO2uKNeFIIkUl5o3b97MzvCv6KdFlBpRJEYsPkZvFlEZKXFKv0qR4Is+i0yJxTI6&amp;#13;
   HkshE7H4FB19t/iD1rZLEvHbcvX0/Qf8/sh/hzfi68tn+9vKyiQuBL15iVIiH+ZCayl+kFp8+T36&amp;#13;
  &lt;attachment/&gt;
  </code></pre>
  
  <p>My question is how to solve the problem of encoding</p>