// UpdateDir.java
//
// You may use and distribute this example. This program is 
// provided WITHOUT WARRANTY either expressed or implied.
//
// Copyright Henrik Björkman 1998
//
//
// History:
// 0.0 Created by Henrik Björkman 1999-09-07
//
// 2000-06-13
// Changed package name to chartplotter_package.

package chartplotter_package;

import java.io.*;

/**
 * This class reads from an input stream and writes 
 * everything read to an output stream (if any).
 */
public class ReadStreamThread extends Thread
{
  DataInputStream in;
  OutputStream out;

  static void error(String str)
  {
    System.err.println("UpdateDir: " + str);
    System.exit(0);
  }

  public ReadStreamThread(InputStream in, OutputStream out)
  {
    this.in=new DataInputStream(in);
    this.out=out;
    this.start();
  }
  
  public void run()
  {
    try
    {
      while (true) 
      {
        int ch=1;
        ch = in.read();
        if (ch<0) break;
        if (out!=null) out.write((char)ch);
      }
    }
    catch(IOException e) 
    {
      error("IOException " + e);
    }
  }
}



