Erick Erickson wrote: > > Sure, just define it in the same scope as you want to refer to it. > Of course, that tells you nothing <G>... > > Java variables go out of scope when the last '}' *at the same level* > is passed. For intance: > > { > string s1; > { > string s2; > } // s2 is out of scope after this line. > // s1 is still available > } > //s1 no longer available. > > So just define your category string "at the appropriate place" outside the > if statement and it will be available *after* the if. You may need to move > it outside the enclosing braces. Or outside the enclosing braces > outside the enclosing braces (as many levels as your braces are > nested that you want to refer to that variable). > >
Thanks, I understand that better now... (I hope). It looks like the best way to do this would be to extract the filename from the path just after the code snippet below: public static Document Document(File f) throws IOException, InterruptedException { // make a new, empty document Document doc = new Document(); // Add the url as a field named "path". Use a field that is // indexed (i.e. searchable), but don't tokenize the field into words. doc.add(new Field("path", f.getPath().replace(dirSep, '/'), Field.Store.YES, Field.Index.UN_TOKENIZED)); This way the filename is available for all the subsequent if {} blocks. Keith. -- View this message in context: http://www.nabble.com/Create-and-populate-a-field-when-indexing-tf4713018.html#a13711541 Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]