Java tutorial
//package com.java2s; import java.net.Socket; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; public class Main { public static String readFrom(Socket s) throws IOException { final BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); StringBuilder sb = new StringBuilder(); String inputLine; while ((inputLine = in.readLine()) != null) {// && !inputLine.equals(RBIConstants.EOM)) { sb.append(inputLine); sb.append("\n"); } in.close(); return sb.toString(); } }