question: public void printEntry ( Writer w ) { try { String indent = "                      " ; int indentWidth = indent . length ( ) ; HardcopyWriter ww = ( HardcopyWriter ) w ; int textSpace = ww . getCharactersPerLine ( ) - indentWidth - 1 ; String newLine = "\n" ; w . write ( newLine , 0 , 1 ) ; String s = "   ID:                " + _id ; w . write ( s , 0 , s . length ( ) ) ; if ( ! ( _consistNumber . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Consist number:    " + _consistNumber ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _roadName . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Road name:         " + _roadName ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _roadNumber . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Road number:       " + _roadNumber ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _model . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Model:             " + _model ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _loco1DccAddress . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Lead Address:      " + _loco1DccAddress + "  " + _loco1Direction ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _loco2DccAddress . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Rear Address:      " + _loco2DccAddress + "  " + _loco2Direction ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _loco3DccAddress . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Mid1 Address:      " + _loco3DccAddress + "  " + _loco3Direction ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _loco4DccAddress . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Mid2 Address:      " + _loco4DccAddress + "  " + _loco4Direction ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _loco5DccAddress . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Mid3 Address:      " + _loco5DccAddress + "  " + _loco5Direction ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _loco6DccAddress . equals ( "" ) ) ) { w . write ( newLine , 0 , 1 ) ; s = "   Mid4 Address:      " + _loco6DccAddress + "  " + _loco6Direction ; w . write ( s , 0 , s . length ( ) ) ; } if ( ! ( _comment . equals ( "" ) ) ) { Vector < String > commentVector = wrapComment ( _comment , textSpace ) ; int k = 0 ; w . write ( newLine , 0 , 1 ) ; s = "   Comment:           " + commentVector . elementAt ( k ) ; w . write ( s , 0 , s . length ( ) ) ; k ++ ; while ( k < commentVector . size ( ) ) { String token = commentVector . elementAt ( k ) ; if ( ! token . equals ( "\n" ) ) { s = indent + token ; } else { s = token ; } w . write ( s , 0 , s . length ( ) ) ; k ++ ; } } w . write ( newLine , 0 , 1 ) ; } catch ( IOException e ) { log . error ( "Error printing ConsistRosterEntry: " + e ) ; } }
target:  Prints the roster information. Updated to allow for multiline comment field. Created separate write statements for text and line feeds to work around the HardcopyWriter bug that misplaces borders