public static void main ( String [ ] args ) throws IOException { if ( args . length != 1 ) { System . out . println ( "Usage: java java " + "-Djava.protocol.handler.pkgs=org.archive.net " + "org.archive.net.rsync.Handler RSYNC_URL" ) ; System . exit ( 1 ) ; } URL u = new URL ( args [ 0 ] ) ; URLConnection connect = u . openConnection ( ) ; // Write download to stdout. final int bufferlength = 4096 ; byte [ ] buffer = new byte [ bufferlength ] ; InputStream is = connect . getInputStream ( ) ; try { for ( int count = is . read ( buffer , 0 , bufferlength ) ; ( count = is . read ( buffer , 0 , bufferlength ) ) != - 1 ; ) { System . out . write ( buffer , 0 , count ) ; } System . out . flush ( ) ; } finally { is . close ( ) ; } }
Main dumps rsync file to STDOUT .