view src/samer/units/DoubleToStream.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
line wrap: on
line source
//
//  DoubleToStream.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 in binary format.
*/

public class DoubleToStream extends AnonymousTask {
	DoubleModel	x;		// data to send
	OutputStream	out;	// stream to write to
	DataOutputStream	objout;
	
	public DoubleToStream(DoubleModel x, OutputStream out) throws Exception
	{
		this.x=x;
		this.out=out;
		objout=new DataOutputStream(out);
	}

	public void dispose() {
		try {
			objout.flush();
			objout.close();
		} catch (Exception ex) {}
		// close out?
	}

	public Task getTask() { return this; }
	
	public void run()  throws Exception {
		objout.writeFloat((float)x.get());
		/* autoflush? */
	}
	public void stopping() {
		try { objout.flush(); }
		catch (Exception ex) {}
	}
}