title: Spring ResourceBundleMessageSource Encoding for Czech MessageResource.getMessage()
body: <p>I have a converter which reader the properties from <strong>.properties</strong> file using <code>ResourceBundleMessageSource</code> for multiple locales e.g en_US,fr_FR,cs_CZ</p>
  
  <p>Below is the xml to read properties.</p>
  
  <pre><code>&lt;bean id="messageSource"
      class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
      &lt;property name="basenames"&gt;
      &lt;list&gt;
              &lt;value&gt;lang/beneficiaryproperty/beneficiary&lt;/value&gt;
              &lt;value&gt;lang/labelsbundlesproperty/labelsbundle&lt;/value&gt;
      &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>And below is the code to read and write the javascript file using <code>File API</code> in java.</p>
  
  <pre><code>String localeAr[]= lang.split("_");
  Locale currentLocale = new Locale(localeAr[0].trim(),localeAr[1].trim());
  file = new File(outputPath +file.separator+ jsFilename + "_" + lang + ".js");
  System.out.println(file.getAbsolutePath());
  System.out.println();
  file.createNewFile();
  buffer.append(disclaimerDetails);
  buffer.append("var " + var + " = \n");
  buffer.append("{ \n");
  
  Iterator iterator = tplPropObj.keySet().iterator();
  while (iterator.hasNext()) 
  {
      String key = (String) iterator.next();
  
          System.out.println("Key : "+key+" -  Label : "+tplPropObj.getProperty(key)+"  -  Locale : "+currentLocale);
  
          String value = messageSource.getMessage(tplPropObj.getProperty(key), new Object[] { }, currentLocale);
  
          System.out.println( "- Value : "+value);
  
          buffer.append("\t" + "\"" + key + "\": ");
          buffer.append("\"" + value + "\"");
  
          if (iterator.hasNext()) 
          {
              buffer.append(",");
          }
      buffer.append("\n");
  }   
  buffer.append("} ");
  
          if(localeAr[1].equalsIgnoreCase("PL") || localeAr[1].equalsIgnoreCase("CZ"))
          {
              Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
              out.write(buffer.toString());
              out.flush();
              out.close();
              buffer.delete(0, buffer.length());
          }
          else
          {
              System.setProperty("file.encoding", "ISO-8859-1");
              BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
              bufferedWriter.write(buffer.toString());
              bufferedWriter.flush();
              bufferedWriter.close();
              buffer.delete(0, buffer.length());
          }
  </code></pre>
  
  <blockquote>
    <p>String value = <strong>messageSource.getMessage(tplPropObj.getProperty(key),
    new Object[] { }, currentLocale)</strong>;</p>
  </blockquote>
  
  <p>Above particular line reads the properties from file having cs_CZ local (File Name </p>
  
  <blockquote>
    <blockquote>
      <p>beneficiary_cs_CZ.properties</p>
    </blockquote>
  </blockquote>
  
  <p>Below are the contents of beneficiary_cs_CZ.properties file..These are saved in STS using <strong>UTF-8 encoding</strong> For czech_language</p>
  
  <pre><code>lbl.beneficiary.name=Z technických důvodů zavřeno.
  lbl.beneficiary.number=123456 
  lbl.beneficiary.loc=Prosím vás, kde je
  divadlo lbl.beneficiary.owner=Mã Người Ký Phát
  </code></pre>
  
  <p>Up to this is oK. But when I read these values from message Resource objects it returns different values
   Below are the values generated from <code>MessageSource</code> object.</p>
  
  <p>-</p>
  
  <blockquote>
    <p>Key : Beneficiary.Name -  Label : lbl.beneficiary.name  -  Locale : cs_CZ
     Value : Z technickÃ½ch dÅ¯vodÅ¯ zavÅ?eno.</p>
    
    <p>Key : Beneficiary.Number -  Label : lbl.beneficiary.number  -  Locale : cs_CZ
     - Value : 123456</p>
    
    <p>Key : Beneficiary.Owner -  Label : lbl.beneficiary.owner  -  Locale : cs_CZ
     - Value : MÃ£ NgÆ°á»?i KÃ½ PhÃ¡t</p>
  </blockquote>
  
  <p>I don' understand why this is happening if I am reading the values from <code>MessageResouce</code> using locale.</p>
  
  <p>Any help ..Appriciated.</p>