Package nom.tam.fits
Class FitsUtil
java.lang.Object
nom.tam.fits.FitsUtil
This class comprises static utility functions used throughout the FITS
classes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
addPadding
(int size) static long
addPadding
(long size) static String[]
byteArrayToStrings
(byte[] bytes, int maxLen) static long
static InputStream
getURLStream
(URL url, int level) static int
static void
pad
(ArrayDataOutput stream, long size) Add padding to an output stream.static void
pad
(ArrayDataOutput stream, long size, byte fill) Add padding to an output stream.static int
padding
(int size) static int
padding
(long size) static void
reposition
(Closeable o, long offset) Reposition a random access stream to a requested offset.static byte[]
stringsToByteArray
(String[] stringArray, int maxLen) Convert an array of Strings to bytes.
-
Method Details
-
addPadding
public static int addPadding(int size) - Parameters:
size
- the current size.- Returns:
- Total size of blocked FITS element, using e.v. padding to fits block size.
-
addPadding
public static long addPadding(long size) - Parameters:
size
- the current size.- Returns:
- Total size of blocked FITS element, using e.v. padding to fits block size.
-
byteArrayToStrings
- Parameters:
bytes
- byte array to convertmaxLen
- the max string length- Returns:
- Convert bytes to Strings.
-
findOffset
- Parameters:
o
- the stream to get the position- Returns:
- Find out where we are in a random access file .
-
getURLStream
- Parameters:
url
- the url to get the stream fromlevel
- max levels of redirection- Returns:
- Get a stream to a URL accommodating possible redirections. Note that if a redirection request points to a different protocol than the original request, then the redirection is not handled automatically.
- Throws:
IOException
- if the operation failed
-
maxLength
- Parameters:
strings
- array of strings to check- Returns:
- Get the maximum length of a String in a String array.
- Throws:
FitsException
- if the operation failed
-
pad
Add padding to an output stream.- Parameters:
stream
- stream to padsize
- the current size- Throws:
FitsException
- if the operation failed
-
pad
Add padding to an output stream.- Parameters:
stream
- stream to padsize
- the current sizefill
- the fill byte to use- Throws:
FitsException
- if the operation failed
-
padding
public static int padding(int size) - Parameters:
size
- the size without padding- Returns:
- How many bytes are needed to fill a 2880 block?
-
padding
public static int padding(long size) -
reposition
Reposition a random access stream to a requested offset.- Parameters:
o
- the closable to repositionoffset
- the offset to position it to.- Throws:
FitsException
- if the operation was failed or not possible
-
stringsToByteArray
Convert an array of Strings to bytes.- Parameters:
stringArray
- the array with StringsmaxLen
- the max length (in bytes) of every String- Returns:
- the resulting bytes
-