Util.ensureLog4JIsConfigured();
final DocumentIterator documentIterator = documentSequence.iterator();
Document document;
FastBufferedOutputStream uriStream = null, titleStream = null;
if ( jsapResult.userSpecified( "uris" ) ) uriStream = new FastBufferedOutputStream( new FileOutputStream( jsapResult.getString( "uris" ) ) );
if ( jsapResult.userSpecified( "titles" ) ) titleStream = new FastBufferedOutputStream( new FileOutputStream( jsapResult.getString( "titles" ) ) );
MutableString s = new MutableString();
ProgressLogger progressLogger = new ProgressLogger( LOGGER, jsapResult.getLong( "logInterval" ), "documents" );
if ( documentSequence instanceof DocumentCollection ) progressLogger.expectedUpdates = ((DocumentCollection)documentSequence).size();
progressLogger.start( "Scanning..." );
while( ( document = documentIterator.nextDocument() ) != null ) {
if ( uriStream != null ) {
s.replace( document.uri() );
s.replace( LINE_TERMINATORS, SPACES );
s.writeUTF8( uriStream );
uriStream.write( '\n' );
}
if ( titleStream != null ) {
s.replace( document.title() );
s.replace( LINE_TERMINATORS, SPACES );
s.writeUTF8( titleStream );
titleStream.write( '\n' );
}
progressLogger.lightUpdate();
}
progressLogger.done();
if ( uriStream != null ) uriStream.close();
if ( titleStream != null ) titleStream.close();
}