Class FitsOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
nom.tam.util.ArrayOutputStream
nom.tam.util.FitsOutputStream
- All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable, ArrayDataOutput, FitsIO, FitsOutput, OutputWriter
- Direct Known Subclasses:
BufferedDataOutputStream
For writing FITS files through an
OutputStream.
Testing and timing for this class is performed in the nom.tam.util.test.BufferedFileTester class.
Version 2.0 -- October 30, 2021: Completely overhauled, with new name and hierarchy. Performance is 2-4 times better than before. (Attila Kovacs)
- See Also:
-
Field Summary
Fields inherited from interface FitsIO
BITS_OF_1_BYTE, BITS_OF_2_BYTES, BITS_OF_3_BYTES, BITS_OF_4_BYTES, BITS_OF_5_BYTES, BITS_OF_6_BYTES, BITS_OF_7_BYTES, BYTE_1_OF_LONG_MASK, BYTE_2_OF_LONG_MASK, BYTE_3_OF_LONG_MASK, BYTE_4_OF_LONG_MASK, BYTE_MASK, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_FLOAT, BYTES_IN_INTEGER, BYTES_IN_LONG, BYTES_IN_SHORT, DEFAULT_BUFFER_SIZE, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASKModifier and TypeFieldDescriptionstatic final intnumber of bits in one byte.static final intnumber of bits in two byte.static final intnumber of bits in three byte.static final intnumber of bits in four byte.static final intnumber of bits in five byte.static final intnumber of bits in six byte.static final intnumber of bits in seven byte.static final longbit mask to get the lowest byte of a long.static final longbit mask to get the second lowest byte of a long.static final longbit mask to get the third lowest byte of a long.static final longbit mask to get the fourth lowest byte of a long.static final intbit mask to get the lowest byte from an integer.static final intnumber of bytes occupied by a boolean.static final intnumber of bytes occupied by a byte.static final intnumber of bytes occupied by a char.static final intnumber of bytes occupied by a double.static final intnumber of bytes occupied by a float.static final intnumber of bytes occupied by a integer.static final intnumber of bytes occupied by a long.static final intnumber of bytes occupied by a short.static final intdefault buffer size to use unless specified otherwise.static final longbit mask to get the highest integer from an long.static final longbit mask to get the lowest integer from an long.static final intbit mask to get the lowest short of a integer.static final longbit mask to get the lowest short of a long. -
Constructor Summary
ConstructorsConstructorDescriptionUse the BufferedOutputStream constructorFitsOutputStream(OutputStream o, int bufLength) Use the BufferedOutputStream constructor -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether we are currently at the start of this output file or stream.voidwrite(boolean[] b, int start, int length) Write a segment of an array of boolean's.voidwrite(byte[] b, int start, int length) Writes up to the specified number of bytes from a buffer to the stream.voidwrite(char[] c, int start, int length) Write a segment of an array of char's.voidwrite(double[] d, int start, int length) Write a segment of an array of double's.voidwrite(float[] f, int start, int length) Write a segment of an array of float's.voidwrite(int b) Writes a byte.voidwrite(int[] i, int start, int length) Write a segment of an array of int's.voidwrite(long[] l, int start, int length) Write a segment of an array of longs.voidwrite(short[] s, int start, int length) Write a segment of an array of shorts.voidWrite a segment of an array of booleans, possibly including legalnullvalues.voidWrite a segment of an array of Strings.voidwriteBoolean(boolean b) voidwriteByte(int b) voidwriteBytes(String s) voidwriteChar(int c) voidwriteChars(String s) voidwriteDouble(double d) voidwriteFloat(float f) voidwriteInt(int i) voidwriteLong(long l) final voidDeprecated.voidwriteShort(int s) voidMethods inherited from class ArrayOutputStream
writeArrayModifier and TypeMethodDescriptionvoidwriteArray(Object o) SeeArrayDataOutput.writeArray(Object)for a contract of this method.Methods inherited from class BufferedOutputStream
flushMethods inherited from class FilterOutputStream
close, writeMethods inherited from class OutputStream
nullOutputStreamMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ArrayDataOutput
flush, write, write, write, write, write, write, write, write, write, writeArrayModifier and TypeMethodDescriptionvoidflush()Flush the output bufferdefault voidwrite(boolean[] buf) Write an array of boolean's.default voidwrite(char[] buf) Write an array of char's.default voidwrite(double[] buf) Write an array of double's.default voidwrite(float[] buf) Write an array of float's.default voidwrite(int[] buf) Write an array of int's.default voidwrite(long[] buf) Write an array of longs.default voidwrite(short[] buf) Write an array of shorts.default voidWrite an array of booleans, including legalnullvalues.default voidWrite an array of Strings.voidwriteArray(Object o) Writes the contents of a Java array to the output translating the data to the required binary representation.Methods inherited from interface DataOutput
write
-
Constructor Details
-
FitsOutputStream
Use the BufferedOutputStream constructor- Parameters:
o- An open output stream.
-
FitsOutputStream
Use the BufferedOutputStream constructor- Parameters:
o- An open output stream.bufLength- The buffer size.
-
-
Method Details
-
write
Description copied from interface:OutputWriterWrites a byte. See the general contract ofDataOutputStream.write(int).- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceOutputWriter- Overrides:
writein classBufferedOutputStream- Parameters:
b- the (unsigned) byte value to write.- Throws:
IOException- if there was an underlying IO error- See Also:
-
write
Description copied from interface:OutputWriterWrites up to the specified number of bytes from a buffer to the stream. See the general contract ofDataOutputStream.write(byte[], int, int).- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceOutputWriter- Overrides:
writein classBufferedOutputStream- Parameters:
b- the bufferstart- the starting buffer indexlength- the number of bytes to write.- Throws:
IOException- if there was an underlying IO error- See Also:
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of boolean's.- Specified by:
writein interfaceArrayDataOutput- Parameters:
b- array of boolean's.start- start index in the arraylength- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of booleans, possibly including legalnullvalues. The method has a default implementation, which callsDataOutput.writeBoolean(boolean)element by element. Classes that implement this interface might want to replace that with a more efficient block read implementation/- Specified by:
writein interfaceArrayDataOutput- Parameters:
buf- array of booleans.offset- start index in the arraysize- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of char's.- Specified by:
writein interfaceArrayDataOutput- Parameters:
c- array of char's.start- start index in the arraylength- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of shorts.- Specified by:
writein interfaceArrayDataOutput- Parameters:
s- the value to writestart- start index in the arraylength- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of int's.- Specified by:
writein interfaceArrayDataOutput- Parameters:
i- array of int'sstart- start index in the arraylength- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of longs.- Specified by:
writein interfaceArrayDataOutput- Parameters:
l- array of longsstart- start index in the arraylength- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of float's.- Specified by:
writein interfaceArrayDataOutput- Parameters:
f- array of float's.start- start index in the arraylength- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of double's.- Specified by:
writein interfaceArrayDataOutput- Parameters:
d- array of double's.start- start index in the arraylength- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
write
Description copied from interface:ArrayDataOutputWrite a segment of an array of Strings. Equivalent to calling writeBytes for the selected elements.- Specified by:
writein interfaceArrayDataOutput- Parameters:
s- the array to writestart- start index in the arraylen- number of array elements to write- Throws:
IOException- if one of the underlying write operations failed
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writePrimitiveArray
Deprecated.useArrayOutputStream.writeArray(Object)insteadDeprecated useArrayOutputStream.writeArray(Object).- Parameters:
o- The object to be written.- Throws:
IOException- if one of the underlying write operations failed
-
isAtStart
public boolean isAtStart()Description copied from interface:FitsOutputChecks whether we are currently at the start of this output file or stream.- Specified by:
isAtStartin interfaceFitsOutput- Returns:
trueif we are currently at the start of stream (where a primary HDU is to be written), orfalseif we are further along, where HDUs should be written as extensions.- See Also:
-
ArrayOutputStream.writeArray(Object)instead