title: How to convert Cp1252 byte array to a proper string?
body: <p>Hi all the code is as follows:</p>
  
  <pre><code>File file2 = new File("D://deploy//body.txt");
  
  byte[] bytes = loadFile(file2);
  System.out.println(bytes.length);
  
  StringBuffer buffer = new StringBuffer();
  InputStream inputStream = new ByteArrayInputStream(bytes);
  InputStreamReader reader = new InputStreamReader(inputStream,"CP1252");
  Reader in = new BufferedReader(reader);
  int ch;
  while ((ch = in.read()) &gt; -1) {
      buffer.append((char)ch);
  }
  in.close(); 
  System.out.println(buffer.toString().getBytes().length);
  </code></pre>
  
  <p>The final result is 1576 and 2439 for the length of the byte arrays. What is a proper way of converting a CP1252 byte array to a string and retain the proper size? Thanks</p>