<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FFile_Input_Output%2FPipedReader</id>
		<title>Java/File Input Output/PipedReader - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FFile_Input_Output%2FPipedReader"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/File_Input_Output/PipedReader&amp;action=history"/>
		<updated>2026-04-21T20:10:46Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/File_Input_Output/PipedReader&amp;diff=6121&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/File_Input_Output/PipedReader&amp;diff=6121&amp;oldid=prev"/>
				<updated>2010-06-01T06:02:28Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:02, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/File_Input_Output/PipedReader&amp;diff=6120&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/File_Input_Output/PipedReader&amp;diff=6120&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:43Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Create PipedReader out of PipedWriter ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Redistributions in binary form must reproduce the above copyright&lt;br /&gt;
 *     notice, this list of conditions and the following disclaimer in the&lt;br /&gt;
 *     documentation and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 *   - Neither the name of Sun Microsystems nor the names of its&lt;br /&gt;
 *     contributors may be used to endorse or promote products derived&lt;br /&gt;
 *     from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS&lt;br /&gt;
 * IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR&lt;br /&gt;
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt;
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt;
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt;
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt;
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.FileReader;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.PipedReader;&lt;br /&gt;
import java.io.PipedWriter;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
import java.io.Reader;&lt;br /&gt;
public class RhymingWords {&lt;br /&gt;
  public static void main(String[] args) throws IOException {&lt;br /&gt;
    FileReader words = new FileReader(&amp;quot;words.txt&amp;quot;);&lt;br /&gt;
    // do the reversing and sorting&lt;br /&gt;
    Reader rhymedWords = reverse(sort(reverse(words)));&lt;br /&gt;
    // write new list to standard out&lt;br /&gt;
    BufferedReader in = new BufferedReader(rhymedWords);&lt;br /&gt;
    String input;&lt;br /&gt;
    while ((input = in.readLine()) != null)&lt;br /&gt;
      System.out.println(input);&lt;br /&gt;
    in.close();&lt;br /&gt;
  }&lt;br /&gt;
  public static Reader reverse(Reader source) throws IOException {&lt;br /&gt;
    BufferedReader in = new BufferedReader(source);&lt;br /&gt;
    PipedWriter pipeOut = new PipedWriter();&lt;br /&gt;
    PipedReader pipeIn = new PipedReader(pipeOut);&lt;br /&gt;
    PrintWriter out = new PrintWriter(pipeOut);&lt;br /&gt;
    new ReverseThread(out, in).start();&lt;br /&gt;
    return pipeIn;&lt;br /&gt;
  }&lt;br /&gt;
  public static Reader sort(Reader source) throws IOException {&lt;br /&gt;
    BufferedReader in = new BufferedReader(source);&lt;br /&gt;
    PipedWriter pipeOut = new PipedWriter();&lt;br /&gt;
    PipedReader pipeIn = new PipedReader(pipeOut);&lt;br /&gt;
    PrintWriter out = new PrintWriter(pipeOut);&lt;br /&gt;
    new SortThread(out, in).start();&lt;br /&gt;
    return pipeIn;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *  - Redistributions of source code must retain the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer.&lt;br /&gt;
 *  - Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 *  - Neither the name of Sun Microsystems nor the names of its contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&lt;br /&gt;
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE&lt;br /&gt;
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
class SortThread extends Thread {&lt;br /&gt;
  private PrintWriter out = null;&lt;br /&gt;
  private BufferedReader in = null;&lt;br /&gt;
  public SortThread(PrintWriter out, BufferedReader in) {&lt;br /&gt;
    this.out = out;&lt;br /&gt;
    this.in = in;&lt;br /&gt;
  }&lt;br /&gt;
  public void run() {&lt;br /&gt;
    int MAXWORDS = 50;&lt;br /&gt;
    if (out != null &amp;amp;&amp;amp; in != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        String[] listOfWords = new String[MAXWORDS];&lt;br /&gt;
        int numwords = 0;&lt;br /&gt;
        while ((listOfWords[numwords] = in.readLine()) != null)&lt;br /&gt;
          numwords++;&lt;br /&gt;
        quicksort(listOfWords, 0, numwords - 1);&lt;br /&gt;
        for (int i = 0; i &amp;lt; numwords; i++)&lt;br /&gt;
          out.println(listOfWords[i]);&lt;br /&gt;
        out.close();&lt;br /&gt;
      } catch (IOException e) {&lt;br /&gt;
        System.err.println(&amp;quot;SortThread run: &amp;quot; + e);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private static void quicksort(String[] a, int lo0, int hi0) {&lt;br /&gt;
    int lo = lo0;&lt;br /&gt;
    int hi = hi0;&lt;br /&gt;
    if (lo &amp;gt;= hi)&lt;br /&gt;
      return;&lt;br /&gt;
    String mid = a[(lo + hi) / 2];&lt;br /&gt;
    while (lo &amp;lt; hi) {&lt;br /&gt;
      while (lo &amp;lt; hi &amp;amp;&amp;amp; a[lo].rupareTo(mid) &amp;lt; 0)&lt;br /&gt;
        lo++;&lt;br /&gt;
      while (lo &amp;lt; hi &amp;amp;&amp;amp; a[hi].rupareTo(mid) &amp;gt; 0)&lt;br /&gt;
        hi--;&lt;br /&gt;
      if (lo &amp;lt; hi) {&lt;br /&gt;
        String T = a[lo];&lt;br /&gt;
        a[lo] = a[hi];&lt;br /&gt;
        a[hi] = T;&lt;br /&gt;
        lo++;&lt;br /&gt;
        hi--;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    if (hi &amp;lt; lo) {&lt;br /&gt;
      int T = hi;&lt;br /&gt;
      hi = lo;&lt;br /&gt;
      lo = T;&lt;br /&gt;
    }&lt;br /&gt;
    quicksort(a, lo0, lo);&lt;br /&gt;
    quicksort(a, lo == lo0 ? lo + 1 : lo, hi0);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc. All rights reserved.&lt;br /&gt;
 * &lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *  - Redistributions of source code must retain the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer.&lt;br /&gt;
 *  - Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 *  - Neither the name of Sun Microsystems nor the names of its contributors may&lt;br /&gt;
 * be used to endorse or promote products derived from this software without&lt;br /&gt;
 * specific prior written permission.&lt;br /&gt;
 * &lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&lt;br /&gt;
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE&lt;br /&gt;
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;br /&gt;
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF&lt;br /&gt;
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;br /&gt;
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)&lt;br /&gt;
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
class ReverseThread extends Thread {&lt;br /&gt;
  private PrintWriter out = null;&lt;br /&gt;
  private BufferedReader in = null;&lt;br /&gt;
  public ReverseThread(PrintWriter out, BufferedReader in) {&lt;br /&gt;
    this.out = out;&lt;br /&gt;
    this.in = in;&lt;br /&gt;
  }&lt;br /&gt;
  public void run() {&lt;br /&gt;
    if (out != null &amp;amp;&amp;amp; in != null) {&lt;br /&gt;
      try {&lt;br /&gt;
        String input;&lt;br /&gt;
        while ((input = in.readLine()) != null) {&lt;br /&gt;
          out.println(reverseIt(input));&lt;br /&gt;
          out.flush();&lt;br /&gt;
        }&lt;br /&gt;
        out.close();&lt;br /&gt;
      } catch (IOException e) {&lt;br /&gt;
        System.err.println(&amp;quot;ReverseThread run: &amp;quot; + e);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private String reverseIt(String source) {&lt;br /&gt;
    int i, len = source.length();&lt;br /&gt;
    StringBuffer dest = new StringBuffer(len);&lt;br /&gt;
    for (i = (len - 1); i &amp;gt;= 0; i--)&lt;br /&gt;
      dest.append(source.charAt(i));&lt;br /&gt;
    return dest.toString();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>