Package gov.usgs.earthquake.product.io
Class IOUtil
- java.lang.Object
-
- gov.usgs.earthquake.product.io.IOUtil
-
public class IOUtil extends java.lang.ObjectClass with main method for converting from one product format to another.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBINARY_FORMATBinary formatstatic java.lang.StringDIRECTORY_FORMATDirectory formatstatic java.lang.StringINFILE_ARGUMENTArgument for input filestatic java.lang.StringINFORMAT_ARGUMENTArgument for input formatstatic java.lang.StringOUTFILE_ARGUMENTArgument for output filestatic java.lang.StringOUTFORMAT_ARGUMENTArgument for output formatstatic java.lang.StringXML_FORMATXML formatstatic java.lang.StringZIP_FORMATZip format
-
Constructor Summary
Constructors Constructor Description IOUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.BufferedInputStreamautoDetectDeflate(java.io.InputStream in)Auto detect an optionally deflated stream.static ProductSourceautoDetectProductSource(java.io.InputStream in)Auto detect an Xml or Binary product source, that is optionally deflated.static ProductHandlergetProductHandler(java.lang.String outformat, java.io.File outfile)Returns a ProductHandler based on the output formatstatic ProductSourcegetProductSource(java.lang.String informat, java.io.File infile)Returns a product source based on input formatstatic voidmain(java.lang.String[] args)Access into IOUtil Takes arguments, gets product source and handler Streams source to handlerstatic voidprintUsage()CLI usage
-
-
-
Field Detail
-
INFILE_ARGUMENT
public static final java.lang.String INFILE_ARGUMENT
Argument for input file- See Also:
- Constant Field Values
-
INFORMAT_ARGUMENT
public static final java.lang.String INFORMAT_ARGUMENT
Argument for input format- See Also:
- Constant Field Values
-
OUTFILE_ARGUMENT
public static final java.lang.String OUTFILE_ARGUMENT
Argument for output file- See Also:
- Constant Field Values
-
OUTFORMAT_ARGUMENT
public static final java.lang.String OUTFORMAT_ARGUMENT
Argument for output format- See Also:
- Constant Field Values
-
ZIP_FORMAT
public static final java.lang.String ZIP_FORMAT
Zip format- See Also:
- Constant Field Values
-
XML_FORMAT
public static final java.lang.String XML_FORMAT
XML format- See Also:
- Constant Field Values
-
DIRECTORY_FORMAT
public static final java.lang.String DIRECTORY_FORMAT
Directory format- See Also:
- Constant Field Values
-
BINARY_FORMAT
public static final java.lang.String BINARY_FORMAT
Binary format- See Also:
- Constant Field Values
-
-
Method Detail
-
getProductHandler
public static ProductHandler getProductHandler(java.lang.String outformat, java.io.File outfile) throws java.io.IOException
Returns a ProductHandler based on the output format- Parameters:
outformat- Output formatoutfile- Output file- Returns:
- a Product Handler
- Throws:
java.io.IOException- if IO error occurs
-
getProductSource
public static ProductSource getProductSource(java.lang.String informat, java.io.File infile) throws java.lang.IllegalArgumentException, java.io.IOException
Returns a product source based on input format- Parameters:
informat- input file formatinfile- input file- Returns:
- a Productsource
- Throws:
java.lang.IllegalArgumentException- if informat argument errorjava.io.IOException- if error occurs
-
autoDetectProductSource
public static ProductSource autoDetectProductSource(java.io.InputStream in) throws java.io.IOException
Auto detect an Xml or Binary product source, that is optionally deflated.- Parameters:
in- input stream containing optionally deflated xml or binary product stream.- Returns:
- ProductSource object.
- Throws:
java.io.IOException- if neither binary or xml product source is in stream.
-
autoDetectDeflate
public static java.io.BufferedInputStream autoDetectDeflate(java.io.InputStream in) throws java.io.IOExceptionAuto detect an optionally deflated stream.- Parameters:
in- input stream containing optionally deflated xml or binary product stream.- Returns:
- ProductSource object.
- Throws:
java.io.IOException- if neither binary or xml product source is in stream.
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionAccess into IOUtil Takes arguments, gets product source and handler Streams source to handler- Parameters:
args- CLI args for infile, informat, outfile, outformat- Throws:
java.lang.Exception- if error occurs
-
printUsage
public static void printUsage()
CLI usage
-
-