Source:
public void onGenericMessage( final GenericMessageEvent event ) { String text = event.getMessage(); Matcher matcher = FOOBAR_NEWS_PATTERN.matcher( text ); Matcher helpMatcher = FOOBAR_NEWS_HELP_PATTERN.matcher( text ); if ( helpMatcher.matches() ) { for ( String line : HELP_MESSAGE.split( "\n" ) ) { event.respondPrivateMessage( line ); } } else if ( matcher.matches() ) { String category = matcher.group( 1 ); if ( category != null && category.equals( "foobar" ) ) { category = null; } else if ( category != null && !QuoteFactDB.getQuotableFactableNicks().contains( category ) ) { event.respond( category + " is not a nick that has facts or quotes." ); return; } HashMap<String, URL> newsFeedsByCategory = new HashMap<>(); try { Path newsFile = Files.createTempFile( "FoobarNews", ".xml" ); logger.info( "Foobar news temp file: " + newsFile.toString() ); RSS rssFeed = createRssFeed( category ); JAXBContext context = JAXBContext.newInstance( RSS.class ); Marshaller marshaller = context.createMarshaller(); try ( FileOutputStream fileOutputStream = new FileOutputStream( newsFile.toFile() ) ) { marshaller.marshal( rssFeed, fileOutputStream ); URL newsFileURL = newsFile.toUri().toURL(); category = ( category != null ) ? category.toLowerCase() : "foobar"; newsFeedsByCategory.put( category, newsFileURL ); logger.info( newsFileURL.toString() ); currentNews( event, matcher, newsFeedsByCategory, category, HELP_COMMAND, limitCommand, RESTRICTED_CHANNEL, logger ); } catch ( IOException e ) { throw e; } } catch ( IOException | JAXBException e ) { event.respond( "I could not create tempoary file for the news :(" ); } } }

Target:
public void onGenericMessage( final GenericMessageEvent event ) { String text = event.getMessage(); Matcher matcher = FOOBAR_NEWS_PATTERN.matcher( text ); Matcher helpMatcher = FOOBAR_NEWS_HELP_PATTERN.matcher( text ); if ( helpMatcher.matches() ) { for ( String line : HELP_MESSAGE.split( "\n" ) ) { event.respondPrivateMessage( line ); } } else if ( matcher.matches() ) { String category = matcher.group( 1 ); if ( category != null && category.equals( "foobar" ) ) { category = null; } else if ( category != null && !QuoteFactDB.getQuotableFactableNicks().contains( category ) ) { event.respond( category + " is not a nick that has facts or quotes." ); return; } HashMap<String, URL> newsFeedsByCategory = new HashMap<>(); try { Path newsFile = Files.createTempFile( "FoobarNews", ".xml" ); logger.info( "Foobar news temp file: " + newsFile.toString() ); RSS rssFeed = createRssFeed( category ); JAXBContext context = JAXBContext.newInstance( RSS.class ); Marshaller marshaller = context.createMarshaller(); try ( FileOutputStream fileOutputStream = new FileOutputStream( newsFile.toFile() ) ) { marshaller.marshal( rssFeed, fileOutputStream ); URL newsFileURL = newsFile.toUri().toURL(); category = ( category != null ) ? category.toLowerCase() : "foobar"; newsFeedsByCategory.put( category, newsFileURL ); logger.info( newsFileURL.toString() ); currentNews( event, matcher, newsFeedsByCategory, category, HELP_COMMAND, limitCommand, RESTRICTED_CHANNEL, logger ); } catch ( IOException e ) { throw e; } } catch ( IOException | JAXBException e ) { event.respond( "I could not create temporary file for the news :(" ); } } }