public static String removeCComments ( final String src ) { final StringBuilder ret = new StringBuilder ( ) ; boolean inComments = false ; for ( int i = 0 ; i < src . length ( ) ; i ++ ) { char c = src . charAt ( i ) ; if ( inComments ) { if ( c == ' ' && src . charAt ( i + 1 ) == ' ' ) { inComments = false ; i ++ ; } } else { if ( c == ' ' ) { if ( src . charAt ( i + 1 ) == ' ' ) { inComments = true ; i ++ ; } else { ret . append ( c ) ; } } else ret . append ( c ) ; } } return ret . toString ( ) ; }
Remove C commentaries .