/Users/mw17785/Projects/gamefinder/gamefinder/trunk/src/example/Handler.java |
package example;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
public class Handler implements Runnable {
private Socket sock;
public Handler(Socket sock) {
this.sock = sock;
new Thread(this).start();
}
public void run() {
try {
InputStream is = sock.getInputStream();
OutputStream os = sock.getOutputStream();
BufferedReader br =
new BufferedReader(new InputStreamReader(is));
PrintStream ps = new PrintStream(os);
String line = br.readLine();
ps.print("You said, '"+line+"'\r\n");
sock.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}