public void replaceLineAt(int pos,String newLines) throws BadLocationException {
  Element e=getParagraphElement(pos);
  replace(e.getStartOffset(),getElementLength(e),newLines,null);
}

public void replaceLineAt ( int pos , String newLines ) throws BadLocationException { Element e = getParagraphElement ( pos ) ; replace ( e . getStartOffset ( ) , getElementLength ( e ) , newLines , null ) ; }
replace the line at given position with the given string , which can span multiple lines
