FingerClientpublic class FingerClient extends SocketClient The FingerClient class implements the client side of the Internet Finger
Protocol defined in RFC 1288. To finger a host you create a
FingerClient instance, connect to the host, query the host, and finally
disconnect from the host. If the finger service you want to query is on
a non-standard port, connect to the host at that port.
Here's a sample use:
FingerClient finger;
finger = new FingerClient();
try {
finger.connect("foo.bar.com");
System.out.println(finger.query("foobar", false));
finger.disconnect();
} catch(IOException e) {
System.err.println("Error I/O exception: " + e.getMessage());
return;
}
|
Fields Summary |
---|
public static final int | DEFAULT_PORTThe default FINGER port. Set to 79 according to RFC 1288. | private static final String | __LONG_FLAG | private transient StringBuffer | __query | private transient char[] | __buffer |
Constructors Summary |
---|
public FingerClient()The default FingerClient constructor. Initializes the
default port to DEFAULT_PORT .
setDefaultPort(DEFAULT_PORT);
|
Methods Summary |
---|
public java.io.InputStream | getInputStream(boolean longOutput, java.lang.String username)Fingers a user and returns the input stream from the network connection
of the finger query. You must first connect to a finger server before
calling this method, and you should disconnect after finishing reading
the stream.
DataOutputStream output;
__query.setLength(0);
if (longOutput)
__query.append(__LONG_FLAG);
__query.append(username);
__query.append(SocketClient.NETASCII_EOL);
output =
new DataOutputStream(new BufferedOutputStream(_output_, 1024));
output.writeBytes(__query.toString());
output.flush();
return _input_;
| public java.io.InputStream | getInputStream(boolean longOutput)Fingers the connected host and returns the input stream from
the network connection of the finger query. This is equivalent to
calling getInputStream(longOutput, ""). You must first connect to a
finger server before calling this method, and you should disconnect
after finishing reading the stream.
return getInputStream(longOutput, "");
| public java.lang.String | query(boolean longOutput, java.lang.String username)Fingers a user at the connected host and returns the output
as a String. You must first connect to a finger server before
calling this method, and you should disconnect afterward.
int read;
StringBuffer result = new StringBuffer(__buffer.length);
BufferedReader input;
input =
new BufferedReader(new InputStreamReader(getInputStream(longOutput,
username)));
while (true)
{
read = input.read(__buffer, 0, __buffer.length);
if (read <= 0)
break;
result.append(__buffer, 0, read);
}
input.close();
return result.toString();
| public java.lang.String | query(boolean longOutput)Fingers the connected host and returns the output
as a String. You must first connect to a finger server before
calling this method, and you should disconnect afterward.
This is equivalent to calling query(longOutput, "") .
return query(longOutput, "");
|
|