Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream());
- StringBuilder result = new StringBuilder();
- //1 way : read char for char from the Inputstream
- int charsRead;
- char[] buff = new char[500];
- while(true){
- charsRead = reader.read(buff);
- if(charsRead < 0)
- break;
- else if(charsRead > 0)
- result.append(String.copyValueOf(buff, 0, charsRead);
- }
- //2 way : only using the buff-var in loop scope
- for(String line = reader.readLine(); line != null; line = reader.readLine())
- result.append(line).append("\n");
- //3 way : using the buff-var outside the loop scope
- String line;
- while(null != (line = reader.readLine()))
- result.append(line).append("\n");
Advertisement
Add Comment
Please, Sign In to add comment