tests/libjava-mauve/src/gnu/testlet/java/io/PipedReaderWriter/PipedTestWriter.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: not-a-test
       
     2 
       
     3 package gnu.testlet.java.io.PipedReaderWriter;
       
     4 import gnu.testlet.TestHarness;
       
     5 import java.io.*;
       
     6 
       
     7 class PipedTestWriter implements Runnable
       
     8 {
       
     9 
       
    10 String str;
       
    11 StringReader sbr;
       
    12 PipedWriter out;
       
    13 TestHarness harness;
       
    14 
       
    15 public
       
    16 PipedTestWriter(TestHarness harness)
       
    17 {
       
    18   this.harness = harness;
       
    19 
       
    20   str = "In college, there was a tradition going for a while that people\n" +
       
    21     "would get together and hang out at Showalter Fountain - in the center\n" +
       
    22     "of Indiana University's campus - around midnight.  It was mostly folks\n" +
       
    23     "from the computer lab and just people who liked to use the Forum\n" +
       
    24     "bbs system on the VAX.  IU pulled the plug on the Forum after I left\n" +
       
    25     "despite its huge popularity.  Now they claim they are just giving\n" +
       
    26     "students what they want by cutting deals to make the campus all\n" +
       
    27     "Microsoft.\n";
       
    28 
       
    29   sbr = new StringReader(str);
       
    30 
       
    31   out = new PipedWriter();
       
    32 }
       
    33 
       
    34 public PipedWriter
       
    35 getWriter()
       
    36 {
       
    37   return(out);
       
    38 }
       
    39 
       
    40 public String
       
    41 getStr()
       
    42 {
       
    43   return(str);
       
    44 }
       
    45 
       
    46 public void
       
    47 run() 
       
    48 {
       
    49   char[] buf = new char[32];
       
    50 
       
    51   int chars_read;
       
    52 
       
    53   try
       
    54     {
       
    55       int b = sbr.read();
       
    56       out.write(b);
       
    57 
       
    58       while ((chars_read = sbr.read(buf)) != -1)
       
    59         out.write(buf, 0, chars_read);
       
    60 	  out.flush();
       
    61       out.close();
       
    62     }
       
    63   catch(IOException e)
       
    64     {
       
    65       harness.debug("In Writer: " + e);
       
    66       harness.check(false);
       
    67     }
       
    68 }
       
    69 
       
    70 } // PipedTestWriter
       
    71