samer@0: // samer@0: // DoubleToStream.java samer@0: // samer@0: // samer@0: // Created by Samer Abdallah on Mon Jun 10 2002. samer@0: // Copyright (c) 2002 __MyCompanyName__. All rights reserved. samer@0: // samer@0: samer@0: package samer.units; samer@0: samer@0: import samer.core.*; samer@0: import samer.core.types.*; samer@0: import samer.tools.*; samer@0: import samer.maths.*; samer@0: import java.io.*; samer@0: samer@0: /** samer@0: Write sequence of doubles to a stream in binary format. samer@0: */ samer@0: samer@0: public class DoubleToStream extends AnonymousTask { samer@0: DoubleModel x; // data to send samer@0: OutputStream out; // stream to write to samer@0: DataOutputStream objout; samer@0: samer@0: public DoubleToStream(DoubleModel x, OutputStream out) throws Exception samer@0: { samer@0: this.x=x; samer@0: this.out=out; samer@0: objout=new DataOutputStream(out); samer@0: } samer@0: samer@0: public void dispose() { samer@0: try { samer@0: objout.flush(); samer@0: objout.close(); samer@0: } catch (Exception ex) {} samer@0: // close out? samer@0: } samer@0: samer@0: public Task getTask() { return this; } samer@0: samer@0: public void run() throws Exception { samer@0: objout.writeFloat((float)x.get()); samer@0: /* autoflush? */ samer@0: } samer@0: public void stopping() { samer@0: try { objout.flush(); } samer@0: catch (Exception ex) {} samer@0: } samer@0: }