Package org.apache.commons.net.finger
Class FingerClient
java.lang.Object
org.apache.commons.net.SocketClient
org.apache.commons.net.finger.FingerClient
- Direct Known Subclasses:
WhoisClient
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; }
-
Field Summary
Fields inherited from class org.apache.commons.net.SocketClient
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL, remoteInetSocketAddress
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetInputStream
(boolean longOutput) Fingers the connected host and returns the input stream from the network connection of the finger query.getInputStream
(boolean longOutput, String user) Fingers a user and returns the input stream from the network connection of the finger query.getInputStream
(boolean longOutput, String user, String encoding) Fingers a user and returns the input stream from the network connection of the finger query.query
(boolean longOutput) Fingers the connected host and returns the output as a String.Fingers a user at the connected host and returns the output as a String.Methods inherited from class org.apache.commons.net.SocketClient
_connectAction_, addProtocolCommandListener, applySocketAttributes, checkOpenOutputStream, connect, connect, connect, connect, connect, connect, createCommandSupport, disconnect, fireCommandSent, fireReplyReceived, getCharset, getCharsetName, getCommandSupport, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemoteInetSocketAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
-
Field Details
-
DEFAULT_PORT
The default FINGER port. Set to 79 according to RFC 1288.- See Also:
-
-
Constructor Details
-
FingerClient
public FingerClient()The default FingerClient constructor. Initializes the default port toDEFAULT_PORT
.
-
-
Method Details
-
getInputStream
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.- Parameters:
longOutput
- Set to true if long output is requested, false if not.- Returns:
- The InputStream of the network connection of the finger query. Can be read to obtain finger results.
- Throws:
IOException
- If an I/O error during the operation.
-
getInputStream
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.- Parameters:
longOutput
- Set to true if long output is requested, false if not.user
- The name of the user to finger.- Returns:
- The InputStream of the network connection of the finger query. Can be read to obtain finger results.
- Throws:
IOException
- If an I/O error during the operation.
-
getInputStream
public InputStream getInputStream(boolean longOutput, String user, String encoding) throws IOException 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.- Parameters:
longOutput
- Set to true if long output is requested, false if not.user
- The name of the user to finger.encoding
- the character encoding that should be used for the query, null for the platform's default encoding- Returns:
- The InputStream of the network connection of the finger query. Can be read to obtain finger results.
- Throws:
IOException
- If an I/O error during the operation.
-
query
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 callingquery(longOutput, "")
.- Parameters:
longOutput
- Set to true if long output is requested, false if not.- Returns:
- The result of the finger query.
- Throws:
IOException
- If an I/O error occurs while reading the socket.
-
query
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.- Parameters:
longOutput
- Set to true if long output is requested, false if not.user
- The name of the user to finger.- Returns:
- The result of the finger query.
- Throws:
IOException
- If an I/O error occurs while reading the socket.
-