1 16 package org.apache.commons.net; 17 18 import java.io.BufferedReader ; 19 import java.io.IOException ; 20 import java.io.InputStreamReader ; 21 22 36 37 public final class DaytimeTCPClient extends SocketClient 38 { 39 40 public static final int DEFAULT_PORT = 13; 41 42 private char[] __buffer = new char[64]; 45 46 50 public DaytimeTCPClient () 51 { 52 setDefaultPort(DEFAULT_PORT); 53 } 54 55 68 public String getTime() throws IOException 69 { 70 int read; 71 StringBuffer result = new StringBuffer (__buffer.length); 72 BufferedReader reader; 73 74 reader = new BufferedReader (new InputStreamReader (_input_)); 75 76 while (true) 77 { 78 read = reader.read(__buffer, 0, __buffer.length); 79 if (read <= 0) 80 break; 81 result.append(__buffer, 0, read); 82 } 83 84 return result.toString(); 85 } 86 87 } 88 89 | Popular Tags |