import java.net.*; import java.io.*; public class Client { Socket socket; OutputStreamWriter writer; BufferedReader reader; public Client() { socket = null; } public void start() { try{ socket = new Socket("localhost", 5555); // 出力ストリームを取得 writer = new OutputStreamWriter(socket.getOutputStream()); reader =new BufferedReader( new InputStreamReader(socket.getInputStream())); }catch(Exception e){;} } public void read() { try{ System.out.println(reader.readLine()); }catch(Exception e){;} } public void close() { try{ writer.close(); reader.close(); socket.close(); }catch(Exception e){;} } public static void main(String args[]) { Client c = new Client(); c.start(); c.read(); c.close(); } }