final Collection<? extends CharSequence> collection;
if ( termFile == null ) {
ArrayList<MutableString> termList = new ArrayList<MutableString>();
final ProgressLogger pl = new ProgressLogger();
pl.itemsName = "URIs";
final LineIterator termIterator = new LineIterator( new FastBufferedReader( new InputStreamReader( System.in, "UTF-8" ), bufferSize ), pl );
pl.start( "Reading URIs..." );
MutableString uri;
while( termIterator.hasNext() ) {
uri = termIterator.next();
if ( uniqueURIs ) makeUnique( filter, uri );
termList.add( uri.copy() );
}
pl.done();
collection = termList;
}
else {
if ( uniqueURIs ) {
// Create temporary file with unique URIs
final ProgressLogger pl = new ProgressLogger();
pl.itemsName = "URIs";
pl.start( "Copying URIs..." );
final LineIterator termIterator = new LineIterator( new FastBufferedReader( new InputStreamReader( new FileInputStream( termFile ) ), bufferSize ), pl );
File temp = File.createTempFile( URLMPHVirtualDocumentResolver.class.getName(), ".uniqueuris" );
temp.deleteOnExit();
termFile = temp.toString();
final FastBufferedOutputStream outputStream = new FastBufferedOutputStream( new FileOutputStream( termFile ), bufferSize );
MutableString uri;
while( termIterator.hasNext() ) {
uri = termIterator.next();
makeUnique( filter, uri );
uri.writeUTF8( outputStream );
outputStream.write( '\n' );
}
pl.done();