List of usage examples for org.apache.poi.hwpf.usermodel Range insertBefore
public CharacterRun insertBefore(String text)
From source file:File.DOC.WriteDoc.java
/** * @param args the command line arguments *//*ww w .ja v a2s . c om*/ public void Write(String path, String namafile, String content) { File file = new File("D:\\xyz.doc"); try { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); HWPFDocument doc = new HWPFDocument(fs); Range range = doc.getRange(); CharacterRun run = range.insertBefore(content.replace("\n", "\013")); run.setBold(true); OutputStream outa = new FileOutputStream(new File(path + namafile + ".doc")); doc.write(outa); out.close(); } catch (Exception e) { System.out.println(e.getMessage()); } }