public static String getJavadoc ( @ Nullable final Class < ? > clazz ) { try { if ( null == clazz ) return null ; @ Nullable final File source = com . simiacryptus . util . lang . CodeUtil . findFile ( clazz ) ; if ( null == source ) return clazz . getName ( ) + " not found" ; final List < String > lines = IOUtils . readLines ( new FileInputStream ( source ) , Charset . forName ( "UTF-8" ) ) ; final int classDeclarationLine = IntStream . range ( 0 , lines . size ( ) ) . filter ( i -> lines . get ( i ) . contains ( "class " + clazz . getSimpleName ( ) ) ) . findFirst ( ) . getAsInt ( ) ; final int firstLine = IntStream . rangeClosed ( 1 , classDeclarationLine ) . map ( i -> classDeclarationLine - i ) . filter ( i -> ! lines . get ( i ) . matches ( "\\s*[/\\*@].*" ) ) . findFirst ( ) . orElse ( - 1 ) + 1 ; final String javadoc = lines . subList ( firstLine , classDeclarationLine ) . stream ( ) . filter ( s -> s . matches ( "\\s*[/\\*].*" ) ) . map ( s -> s . replaceFirst ( "^[ \t]*[/\\*]+" , "" ) . trim ( ) ) . filter ( x -> ! x . isEmpty ( ) ) . reduce ( ( a , b ) -> a + "\n" + b ) . orElse ( "" ) ; return javadoc . replaceAll ( "<p>" , "\n" ) ; } catch ( @ javax . annotation . Nonnull final Throwable e ) { e . printStackTrace ( ) ; return "" ; } }
Gets javadoc .