Code example for PrintWriter

Methods: close, flush

0
        return "text/xml"; 
    } 
 
    @Override 
    protected void onRender(final MarkupStream markupStream) { 
        PrintWriter writer = new PrintWriter(getResponse().getOutputStream()); 
        try { 
            getFeed().writeFeed(writer); 
            writer.flush(); 
        } catch (IOException e) { 
            throw new WicketRuntimeException("unable to construct sitemap.xml for request: " + ((WebRequest) getRequest()).getHttpServletRequest().getRemoteAddr(), e); 
        } finally { 
            writer.close(); 
        } 
    } 
 
    protected abstract SiteMapFeed getFeed(); 
 
}