title: java encoding issue while reading stream
body: <p>I am trying to download contents from ftp folder. There is one xml file which starts with standardazed xml codes.</p>
  
  <pre><code>&lt; ?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p>when i read these files (using java.net.Socket)and get input stream and then try to convert to String, somehow i get some new charecters. And the whole xml document starts with '?' eg. "?&lt; ?xml version="1.0" encoding="utf-8"?>....."</p>
  
  <pre><code>BufferedInputStream reader = new BufferedInputStream(sock.getInputStream());
  </code></pre>
  
  <p>Then i  am getting a string from this reader using following code.</p>
  
  <pre><code>StringBuilder sb = new StringBuilder();
  
  String line;
  BufferedReader br = new BufferedReader(new InputStreamReader(reader));
  
  while ((line = br.readLine()) != null) {
      sb.append(line);
  }
  System.out.println ("sb.toString()");
  </code></pre>
  
  <p>Not sure whats happening here. why am i getting some special charecters introduced ?Any suggestions would be appreciated</p>
  
  <p>and then i just used following code to read the file and in console i see some special charecters</p>
  
  <pre><code>BufferedReader reader = new BufferedReader(new     FileReader("c:/Users/appd922/DocumentMeta06122014.xml"));
  StringBuffer sb = new StringBuffer();
  String line = null;
  while ((line = reader.readLine()) != null) {
  sb.append(line);
  }
  
  String output = sb.toString();
  System.out.println("reading from file"+output);
  </code></pre>
  
  <p>I got output starting 
  "reading from fileï»¿&lt; ?xml version.....</p>
  
  <p>where am i getting these special charecters ?</p>
  
  <p>Note- ignore the space in the xml file line given above. i could not write here with proper xmlwithout that space.</p>