public static String indentBlock ( String block , Indent indent ) { StringBuilder sb = new StringBuilder ( ) ; BufferedReader br = new BufferedReader ( new StringReader ( block ) ) ; String line ; try { while ( ( line = br . readLine ( ) ) != null ) sb . append ( indent ) . append ( line ) . append ( ' ' ) ; } catch ( IOException ex ) { // on a String ? I doubt... } return sb . toString ( ) ; }
Indents a block of text . You provide the block of text as a String and the indent object and it returns another String with each line properly indented .