ewe.io
Class IOTransfer

java.lang.Object
  extended byewe.sys.TaskObject
      extended byewe.io.IOTransfer
All Implemented Interfaces:
Runnable, Task

public class IOTransfer
extends TaskObject

This class is used to copy from one stream to another asynchronously.


Field Summary
 int bufferSize
           
 int checkTime
          This is how long it waits (in milliseconds) between checking the task Handle for an abort request.
 int copied
          This is the number of bytes copied so far.
 Stream in
           
 Stream out
           
 int sleepTime
           
 boolean stopAfterTotalToCopy
          Set this to true if you want to stop after totalToCopy has been reached.
 int totalToCopy
          If you know how many bytes are to be copied, then set this value.
protected  boolean transferred
           
 
Fields inherited from class ewe.sys.TaskObject
handle, interruptThreadToStop, myThread, napIterations, napTime, shouldStop
 
Constructor Summary
IOTransfer()
          After calling this constructor you can call start(Stream in,Stream out) to begin the transfer operation running asynchronously.
IOTransfer(Stream in, Stream out)
          After calling this constructor you can call startTask() to begin the transfer operation running asynchronously.
IOTransfer(Stream in, Stream out, int totalToCopy)
          After calling this constructor you can call startTask() to begin the transfer operation running asynchronously.
 
Method Summary
 void closeStreams()
           
protected  void doRun()
          This is the method that runs in its own Coroutine thread.
 boolean run(Stream in, Stream out)
          Deprecated. - use transfer(in,out) instead.
 Handle start(Stream in, Stream out)
          Start the transfer asynchronously and return a Handle.
protected  boolean transfer()
          This is the method that runs in its own Coroutine thread.
 void transfer(Stream in, Stream out)
          Copy from the "in" stream to the "out" stream.
 
Methods inherited from class ewe.sys.TaskObject
checkAbortFail, checkFailure, doStart, doStop, exec, getHandle, nap, run, setNapTime, show, sleep, start, startTask, stopTask, waitOn, waitOnAny, waitOnSuccess, yield, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

in

public Stream in

out

public Stream out

bufferSize

public int bufferSize

sleepTime

public int sleepTime

checkTime

public int checkTime
This is how long it waits (in milliseconds) between checking the task Handle for an abort request. By default it is 100.


copied

public int copied
This is the number of bytes copied so far.


totalToCopy

public int totalToCopy
If you know how many bytes are to be copied, then set this value.


stopAfterTotalToCopy

public boolean stopAfterTotalToCopy
Set this to true if you want to stop after totalToCopy has been reached.


transferred

protected boolean transferred
Constructor Detail

IOTransfer

public IOTransfer()
After calling this constructor you can call start(Stream in,Stream out) to begin the transfer operation running asynchronously.


IOTransfer

public IOTransfer(Stream in,
                  Stream out)
After calling this constructor you can call startTask() to begin the transfer operation running asynchronously.


IOTransfer

public IOTransfer(Stream in,
                  Stream out,
                  int totalToCopy)
After calling this constructor you can call startTask() to begin the transfer operation running asynchronously.

Method Detail

start

public Handle start(Stream in,
                    Stream out)
Start the transfer asynchronously and return a Handle.


run

public boolean run(Stream in,
                   Stream out)
Deprecated. - use transfer(in,out) instead.

This runs it synchronously. It will not return until it is done.


transfer

public void transfer(Stream in,
                     Stream out)
              throws IOException
Copy from the "in" stream to the "out" stream. The streams are NOT closed.

Throws:
IOException

transfer

protected boolean transfer()
This is the method that runs in its own Coroutine thread.


doRun

protected void doRun()
This is the method that runs in its own Coroutine thread.

Overrides:
doRun in class TaskObject

closeStreams

public void closeStreams()