FreeHEP API
Version current

hep.io.xdr
Class XDROutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended byjava.io.DataOutputStream
              extended byhep.io.xdr.XDROutputStream
All Implemented Interfaces:
DataOutput, XDRDataOutput

public class XDROutputStream
extends DataOutputStream
implements XDRDataOutput

A class for writing XDR files. Not too hard to do in Java since the XDR format is very similar to the Java native DataStream format, except for String and the fact that elements (ro an array of elements) are always padded to a multiple of 4 bytes. This class requires the user to call the pad method, to skip to the next 4-byte boundary after writing an element or array of elements that may not span a multiple of 4 bytes.

Version:
$Id: XDROutputStream.java,v 1.4 2003/09/16 23:11:55 tonyj Exp $
Author:
Tony Johnson (tonyj@slac.stanford.edu)
Source Code:
XDROutputStream.java

Field Summary
 
Fields inherited from class java.io.DataOutputStream
written
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
XDROutputStream(OutputStream out)
           
 
Method Summary
 long getBytesWritten()
           
 void pad()
          Skips appropriate amount to bring stream to 4-byte boundary.
 void writeDoubleArray(double[] array)
           
 void writeDoubleArray(double[] array, int start, int n)
           
 void writeFloatArray(float[] array)
           
 void writeFloatArray(float[] array, int start, int n)
           
 void writeIntArray(int[] array)
           
 void writeIntArray(int[] array, int start, int n)
           
 void writeString(String s)
          Write a string preceeded by its (int) length
 void writeStringChars(String s)
          Write a string (no length is written)
 
Methods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.io.FilterOutputStream
close, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataOutput
write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 

Constructor Detail

XDROutputStream

public XDROutputStream(OutputStream out)
Method Detail

writeString

public void writeString(String s)
                 throws IOException
Description copied from interface: XDRDataOutput
Write a string preceeded by its (int) length

Specified by:
writeString in interface XDRDataOutput
Throws:
IOException

writeStringChars

public void writeStringChars(String s)
                      throws IOException
Description copied from interface: XDRDataOutput
Write a string (no length is written)

Specified by:
writeStringChars in interface XDRDataOutput
Throws:
IOException

writeIntArray

public void writeIntArray(int[] array)
                   throws IOException
Specified by:
writeIntArray in interface XDRDataOutput
Throws:
IOException

writeIntArray

public void writeIntArray(int[] array,
                          int start,
                          int n)
                   throws IOException
Specified by:
writeIntArray in interface XDRDataOutput
Throws:
IOException

writeDoubleArray

public void writeDoubleArray(double[] array)
                      throws IOException
Specified by:
writeDoubleArray in interface XDRDataOutput
Throws:
IOException

writeDoubleArray

public void writeDoubleArray(double[] array,
                             int start,
                             int n)
                      throws IOException
Specified by:
writeDoubleArray in interface XDRDataOutput
Throws:
IOException

writeFloatArray

public void writeFloatArray(float[] array)
                     throws IOException
Specified by:
writeFloatArray in interface XDRDataOutput
Throws:
IOException

writeFloatArray

public void writeFloatArray(float[] array,
                            int start,
                            int n)
                     throws IOException
Specified by:
writeFloatArray in interface XDRDataOutput
Throws:
IOException

pad

public void pad()
         throws IOException
Skips appropriate amount to bring stream to 4-byte boundary.

Specified by:
pad in interface XDRDataOutput
Throws:
IOException

getBytesWritten

public long getBytesWritten()

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.