Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 19860 invoked from network); 17 Feb 2008 23:07:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Feb 2008 23:07:42 -0000 Received: (qmail 79634 invoked by uid 500); 17 Feb 2008 23:07:35 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 79557 invoked by uid 500); 17 Feb 2008 23:07:35 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 79547 invoked by uid 99); 17 Feb 2008 23:07:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Feb 2008 15:07:35 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Feb 2008 23:06:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5844A1A9832; Sun, 17 Feb 2008 15:07:02 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r628574 - /commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/finger/FingerClient.java Date: Sun, 17 Feb 2008 23:07:02 -0000 To: commits@commons.apache.org From: rwinston@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080217230706.5844A1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rwinston Date: Sun Feb 17 15:07:00 2008 New Revision: 628574 URL: http://svn.apache.org/viewvc?rev=628574&view=rev Log: NET-164 Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/finger/FingerClient.java Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/finger/FingerClient.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/finger/FingerClient.java?rev=628574&r1=628573&r2=628574&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/finger/FingerClient.java (original) +++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/finger/FingerClient.java Sun Feb 17 15:07:00 2008 @@ -1,12 +1,11 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Copyright 2001-2005 The Apache Software Foundation * - * http://www.apache.org/licenses/LICENSE-2.0 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,17 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.commons.net; -package org.apache.commons.net.finger; - -import java.io.BufferedOutputStream; import java.io.BufferedReader; -import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; - -import org.apache.commons.net.SocketClient; +import java.io.BufferedOutputStream; +import java.io.DataOutputStream; /*** * The FingerClient class implements the client side of the Internet Finger @@ -139,6 +135,26 @@ public InputStream getInputStream(boolean longOutput, String username) throws IOException { + return getInputStream(longOutput, username, null); + } + + /*** + * 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. + *

+ * @param longOutput Set to true if long output is requested, false if not. + * @param username The name of the user to finger. + * @param encoding the character encoding that should be used for the query, + * null for the platform's default encoding + * @return The InputStream of the network connection of the finger query. + * Can be read to obtain finger results. + * @exception IOException If an I/O error during the operation. + ***/ + public InputStream getInputStream(boolean longOutput, String username, String encoding) + throws IOException + { DataOutputStream output; __query.setLength(0); @@ -146,10 +162,12 @@ __query.append(__LONG_FLAG); __query.append(username); __query.append(SocketClient.NETASCII_EOL); + + byte[] encodedQuery = + (encoding == null ? __query.toString().getBytes() : __query.toString().getBytes(encoding)); - output = - new DataOutputStream(new BufferedOutputStream(_output_, 1024)); - output.writeBytes(__query.toString()); + output = new DataOutputStream(new BufferedOutputStream(_output_, 1024)); + output.write(encodedQuery, 0, encodedQuery.length); output.flush(); return _input_;