Author: rwinston Date: Sat Apr 4 19:25:29 2009 New Revision: 761991 URL: http://svn.apache.org/viewvc?rev=761991&view=rev Log: * NET-252 Remove deprecated API * Move IOUtil.java to utils/ package
Added: commons/proper/net/branches/NET_2_0/src/main/java/examples/util/ commons/proper/net/branches/NET_2_0/src/main/java/examples/util/IOUtil.java (with props) Removed: commons/proper/net/branches/NET_2_0/src/main/java/examples/IOUtil.java Modified: commons/proper/net/branches/NET_2_0/src/main/java/examples/rexec.java commons/proper/net/branches/NET_2_0/src/main/java/examples/rlogin.java commons/proper/net/branches/NET_2_0/src/main/java/examples/rshell.java commons/proper/net/branches/NET_2_0/src/main/java/examples/weatherTelnet.java commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java Modified: commons/proper/net/branches/NET_2_0/src/main/java/examples/rexec.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/examples/rexec.java?rev=761991&r1=761990&r2=761991&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/examples/rexec.java (original) +++ commons/proper/net/branches/NET_2_0/src/main/java/examples/rexec.java Sat Apr 4 19:25:29 2009 @@ -20,6 +20,8 @@ import java.io.IOException; import org.apache.commons.net.bsd.RExecClient; +import examples.util.IOUtil; + /*** * This is an example program demonstrating how to use the RExecClient class. * This program connects to an rexec server and requests that the Modified: commons/proper/net/branches/NET_2_0/src/main/java/examples/rlogin.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/examples/rlogin.java?rev=761991&r1=761990&r2=761991&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/examples/rlogin.java (original) +++ commons/proper/net/branches/NET_2_0/src/main/java/examples/rlogin.java Sat Apr 4 19:25:29 2009 @@ -20,6 +20,8 @@ import java.io.IOException; import org.apache.commons.net.bsd.RLoginClient; +import examples.util.IOUtil; + /*** * This is an example program demonstrating how to use the RLoginClient * class. This program connects to an rlogin daemon and begins to Modified: commons/proper/net/branches/NET_2_0/src/main/java/examples/rshell.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/examples/rshell.java?rev=761991&r1=761990&r2=761991&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/examples/rshell.java (original) +++ commons/proper/net/branches/NET_2_0/src/main/java/examples/rshell.java Sat Apr 4 19:25:29 2009 @@ -20,6 +20,8 @@ import java.io.IOException; import org.apache.commons.net.bsd.RCommandClient; +import examples.util.IOUtil; + /*** * This is an example program demonstrating how to use the RCommandClient * class. This program connects to an rshell daemon and requests that the Added: commons/proper/net/branches/NET_2_0/src/main/java/examples/util/IOUtil.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/examples/util/IOUtil.java?rev=761991&view=auto ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/examples/util/IOUtil.java (added) +++ commons/proper/net/branches/NET_2_0/src/main/java/examples/util/IOUtil.java Sat Apr 4 19:25:29 2009 @@ -0,0 +1,104 @@ +/* + * 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 + * + * 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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package examples.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import org.apache.commons.net.io.Util; + +/*** + * This is a utility class providing a reader/writer capability required + * by the weatherTelnet, rexec, rshell, and rlogin example programs. + * The only point of the class is to hold the static method readWrite + * which spawns a reader thread and a writer thread. The reader thread + * reads from a local input source (presumably stdin) and writes the + * data to a remote output destination. The writer thread reads from + * a remote input source and writes to a local output destination. + * The threads terminate when the remote input source closes. + * <p> + ***/ + +public final class IOUtil +{ + + public static final void readWrite(final InputStream remoteInput, + final OutputStream remoteOutput, + final InputStream localInput, + final OutputStream localOutput) + { + Thread reader, writer; + + reader = new Thread() + { + public void run() + { + int ch; + + try + { + while (!interrupted() && (ch = localInput.read()) != -1) + { + remoteOutput.write(ch); + remoteOutput.flush(); + } + } + catch (IOException e) + { + //e.printStackTrace(); + } + } + } + ; + + + writer = new Thread() + { + public void run() + { + try + { + Util.copyStream(remoteInput, localOutput); + } + catch (IOException e) + { + e.printStackTrace(); + System.exit(1); + } + } + }; + + + writer.setPriority(Thread.currentThread().getPriority() + 1); + + writer.start(); + reader.setDaemon(true); + reader.start(); + + try + { + writer.join(); + reader.interrupt(); + } + catch (InterruptedException e) + { + } + } + +} + Propchange: commons/proper/net/branches/NET_2_0/src/main/java/examples/util/IOUtil.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/proper/net/branches/NET_2_0/src/main/java/examples/weatherTelnet.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/examples/weatherTelnet.java?rev=761991&r1=761990&r2=761991&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/examples/weatherTelnet.java (original) +++ commons/proper/net/branches/NET_2_0/src/main/java/examples/weatherTelnet.java Sat Apr 4 19:25:29 2009 @@ -20,6 +20,8 @@ import java.io.IOException; import org.apache.commons.net.telnet.TelnetClient; +import examples.util.IOUtil; + /*** * This is an example of a trivial use of the TelnetClient class. * It connects to the weather server at the University of Michigan, Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java?rev=761991&r1=761990&r2=761991&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java (original) +++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/FTPListParseEngine.java Sat Apr 4 19:25:29 2009 @@ -83,7 +83,7 @@ } /** - * handle the iniitial reading and preparsing of the list returned by + * handle the initial reading and preparsing of the list returned by * the server. After this method has completed, this object will contain * a list of unparsed entries (Strings) each referring to a unique file * on the server. @@ -102,27 +102,7 @@ resetIterator(); } - /** - * handle the iniitial reading and preparsing of the list returned by - * the server. After this method has completed, this object will contain - * a list of unparsed entries (Strings) each referring to a unique file - * on the server. - * - * @param stream input stream provided by the server socket. - * - * @exception IOException - * thrown on any failure to read from the sever. - * - * @deprecated The version of this method which takes an encoding should be used. - */ - public void readServerList(InputStream stream) - throws IOException - { - readServerList(stream, null); - } - - - + /** * Internal method for reading the input into the <code>entries</code> list. * After this method has completed, <code>entries</code> will contain a Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java?rev=761991&r1=761990&r2=761991&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java (original) +++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java Sat Apr 4 19:25:29 2009 @@ -116,7 +116,7 @@ ***/ public FTPFile[] parseFileList(InputStream listStream) throws IOException { FTPListParseEngine engine = new FTPListParseEngine(this); - engine.readServerList(listStream); + engine.readServerList(listStream, null); return engine.getFiles(); } Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java?rev=761991&r1=761990&r2=761991&view=diff ============================================================================== --- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java (original) +++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java Sat Apr 4 19:25:29 2009 @@ -93,7 +93,7 @@ parser.configure(null); FTPListParseEngine engine = new FTPListParseEngine(parser); engine.readServerList( - new ByteArrayInputStream(fullListing.getBytes())); + new ByteArrayInputStream(fullListing.getBytes()), null); // use default encoding FTPFile[] files = engine.getFiles(); assertEquals(6, files.length); assertFileInListing(files, "2-JUN.LIS"); @@ -114,7 +114,7 @@ parser.configure(null); FTPListParseEngine engine = new FTPListParseEngine(parser); engine.readServerList( - new ByteArrayInputStream(fullListing.getBytes())); + new ByteArrayInputStream(fullListing.getBytes()), null); // use default encoding FTPFile[] files = engine.getFiles(); assertEquals(3, files.length); assertFileInListing(files, "1-JUN.LIS;1");