title: Size of a char on Android
body: <p>According to Java specification, the size of a <a href="http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html" rel="nofollow">char</a> data type is 16 bits or two bytes.</p>
  
  <p>So, I have the written following code: </p>
  
  <pre><code>private static final int BUFFER_SIZE=1024;
  char[] buffer=new char[BUFFER_SIZE];
  BufferedReader br= new BufferedReader(new InputStreamReader(conn.getInputStream()));
  
  while (true){
      byteFromStream=in.read(buffer);
      if (byteFromStream==-1) break;
      totalBytesLoaded=totalBytesLoaded+byteFromStream*2;
  }
  </code></pre>
  
  <p>But for some strange reason I am reading more bytes then is available on the stream, according to the specification of <a href="http://developer.android.com/reference/java/io/Reader.html#read%28char%5b%5d,%20int,%20int%29" rel="nofollow">read()</a> return numbers of characters actually read by stream. </p>
  
  <p>Oh, I am getting total stream size by</p>
  
  <pre><code>bytesTotal=conn.getContentLength();
  </code></pre>
  
  <p>Which is working pretty fine as I myself uploaded files on the server and I know their sizes.</p>