Mercurial > hg > jslab
view src/samer/units/DoubleWriter.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
line wrap: on
line source
// // DoubleWriter.java // // // Created by Samer Abdallah on Mon Jun 10 2002. // Copyright (c) 2002 __MyCompanyName__. All rights reserved. // package samer.units; import samer.core.*; import samer.core.types.*; import samer.tools.*; import samer.maths.*; import java.io.*; /** Write sequence of doubles to a stream as text */ public class DoubleWriter extends AnonymousTask { DoubleModel x; // data to send OutputStream out; // stream to write to PrintStream prn; public DoubleWriter(DoubleModel x, OutputStream out) throws Exception { this(x,out,true); } public DoubleWriter(DoubleModel x, OutputStream out, boolean autoflush) throws Exception { this.x=x; this.out=out; prn=new PrintStream(out,autoflush); // autoflush or not? } public void dispose() { try { prn.flush(); prn.close(); } catch (Exception ex) {} // close out? } public Task getTask() { return this; } public void run() throws Exception { prn.println(x.get()); // how often should we flush? } public void stopping() { try { prn.flush(); } catch (Exception ex) {} } }