Package nom.tam.util
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 nom.tam.util.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_MASK
-
Constructor Summary
ConstructorDescriptionUse the BufferedOutputStream constructorFitsOutputStream
(OutputStream o, int bufLength) Use the BufferedOutputStream constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether we are currently at the start of this output file or stream.void
write
(boolean[] b, int start, int length) Write a segment of an array of boolean's.void
write
(byte[] b, int start, int length) Writes up to the specified number of bytes from a buffer to the stream.void
write
(char[] c, int start, int length) Write a segment of an array of char's.void
write
(double[] d, int start, int length) Write a segment of an array of double's.void
write
(float[] f, int start, int length) Write a segment of an array of float's.void
write
(int b) Writes a byte.void
write
(int[] i, int start, int length) Write a segment of an array of int's.void
write
(long[] l, int start, int length) Write a segment of an array of longs.void
write
(short[] s, int start, int length) Write a segment of an array of shorts.void
Write a segment of an array of booleans, possibly including legalnull
values.void
Write a segment of an array of Strings.void
writeBoolean
(boolean b) void
writeByte
(int b) void
writeBytes
(String s) void
writeChar
(int c) void
writeChars
(String s) void
writeDouble
(double d) void
writeFloat
(float f) void
writeInt
(int i) void
writeLong
(long l) final void
Deprecated.void
writeShort
(int s) void
Methods inherited from class nom.tam.util.ArrayOutputStream
writeArray
Methods inherited from class java.io.BufferedOutputStream
flush
Methods inherited from class java.io.FilterOutputStream
close, write
Methods inherited from class java.io.OutputStream
nullOutputStream
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nom.tam.util.ArrayDataOutput
flush, write, write, write, write, write, write, write, write, write, writeArray
Methods inherited from interface java.io.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:OutputWriter
Writes a byte. See the general contract ofDataOutputStream.write(int)
.- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfaceOutputWriter
- Overrides:
write
in 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:OutputWriter
Writes up to the specified number of bytes from a buffer to the stream. See the general contract ofDataOutputStream.write(byte[], int, int)
.- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfaceOutputWriter
- Overrides:
write
in 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:ArrayDataOutput
Write a segment of an array of boolean's.- Specified by:
write
in 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:ArrayDataOutput
Write a segment of an array of booleans, possibly including legalnull
values. 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:
write
in 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:ArrayDataOutput
Write a segment of an array of char's.- Specified by:
write
in 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:ArrayDataOutput
Write a segment of an array of shorts.- Specified by:
write
in 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:ArrayDataOutput
Write a segment of an array of int's.- Specified by:
write
in 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:ArrayDataOutput
Write a segment of an array of longs.- Specified by:
write
in 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:ArrayDataOutput
Write a segment of an array of float's.- Specified by:
write
in 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:ArrayDataOutput
Write a segment of an array of double's.- Specified by:
write
in 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:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChars
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-
write
Description copied from interface:ArrayDataOutput
Write a segment of an array of Strings. Equivalent to calling writeBytes for the selected elements.- Specified by:
write
in 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:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeChar
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeShort
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
- Specified by:
writeDouble
in 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:FitsOutput
Checks whether we are currently at the start of this output file or stream.- Specified by:
isAtStart
in interfaceFitsOutput
- Returns:
true
if we are currently at the start of stream (where a primary HDU is to be written), orfalse
if we are further along, where HDUs should be written as extensions.- See Also:
-
ArrayOutputStream.writeArray(Object)
instead