the method below return data from InputStream as a string where the string will be constructed using StringBuilder
String getBytes(InputStream is) throws IOException{
StringBuilder sb = new StringBuilder();
int ch;
while ((ch = is.read()) != -1) sb.append((char)ch);
is.close();
return sb.toString();
}
but this method doesnt work properly for image data. the best solution is to build the similar method but returning byte[] rather than string. can one show me how?