static public void main ( String [ ] sa ) throws IOException , TarMalformatException { if ( sa . length < 1 ) { System . out . println ( RB . singleton . getString ( RB . TARREADER_SYNTAX , TarReader . class . getName ( ) ) ) ; System . out . println ( RB . singleton . getString ( RB . LISTING_FORMAT ) ) ; System . exit ( 0 ) ; } File exDir = ( sa . length > 1 && sa [ 1 ] . startsWith ( "--directory=" ) ) ? ( new File ( sa [ 1 ] . substring ( "--directory=" . length ( ) ) ) ) : null ; int firstPatInd = ( exDir == null ) ? 2 : 3 ; if ( sa . length < firstPatInd || ( ( ! sa [ 0 ] . equals ( "t" ) ) && ! sa [ 0 ] . equals ( "x" ) ) ) { throw new IllegalArgumentException ( RB . singleton . getString ( RB . TARREADER_SYNTAXERR , TarReader . class . getName ( ) ) ) ; } String [ ] patternStrings = null ; if ( sa . length > firstPatInd ) { patternStrings = new String [ sa . length - firstPatInd ] ; for ( int i = firstPatInd ; i < sa . length ; i ++ ) { patternStrings [ i - firstPatInd ] = sa [ i ] ; } } if ( sa [ 0 ] . equals ( "t" ) && exDir != null ) { throw new IllegalArgumentException ( RB . singleton . getString ( RB . DIR_X_CONFLICT ) ) ; } int dirIndex = ( exDir == null ) ? 1 : 2 ; int tarReaderMode = sa [ 0 ] . equals ( "t" ) ? LIST_MODE : EXTRACT_MODE ; new TarReader ( new File ( sa [ dirIndex ] ) , tarReaderMode , patternStrings , null , exDir ) . read ( ) ; }
Reads a specified tar file or stdin in order to either list or extract the file tar entries depending on the first argument being t or x using default read buffer blocks .