public int writeDirectory ( HttpServletResponse res , File dir , String path ) throws IOException { // error checking if ( dir == null ) { res . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; return 0 ; } if ( ! dir . exists ( ) || ! dir . isDirectory ( ) ) { res . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; return 0 ; } // Get directory as HTML String dirHtmlString = getDirectory ( path , dir ) ; thredds . servlet . ServletUtil . setResponseContentLength ( res , dirHtmlString ) ; res . setContentType ( ContentType . html . getContentHeader ( ) ) ; PrintWriter writer = res . getWriter ( ) ; writer . write ( dirHtmlString ) ; writer . flush ( ) ; return dirHtmlString . length ( ) ; }
Write a file directory .