I am trying to download XML document from Server. From my log I see that I am getting complete document; however, when I convert the document into String, I only have 4096 bytes.
private String getString(InputStream inputStream) {
byte[] arrayOfByte = new byte[2048];
StringBuffer sB = new StringBuffer();
try {
while (true)
{
int i = inputStream.read(arrayOfByte);
if (i == -1) {
return sB.toString();
}
sB.append(new String(arrayOfByte, 0, i));
}
} catch (IOException e) {
}
return null;
}
Can anybody give any explanation on what i am doing wrong ?
Personally, I always use Apache Commons IO for this kind of stuff:
However, your code looks okay, so the error is probably somewhere else.