Advertisement
Guest User

Код

a guest
Feb 8th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. class OutDoc
  2. {
  3.     OutDoc() throws FileNotFoundException, IOException, InvalidFormatException
  4.     {
  5.         File fil1=new File(FileSelect.patchin);
  6.         File fil2=new File("C:\\Users\\Капитошка\\Desktop\\nullfile.docx");
  7.         Files.copy(fil1.toPath(), fil2.toPath());
  8.         try{
  9.         FileInputStream strr=new FileInputStream(FileSelect.patchin);
  10.         final XWPFDocument doc = new XWPFDocument(strr);
  11.         XWPFParagraph p1 = doc.createParagraph();
  12.         XWPFRun r1 = p1.createRun();
  13.         textField.getField();
  14.         r1.setText(textField.finaltxt);
  15.         final FileOutputStream out = new FileOutputStream(FileSelect.patchin);
  16.         doc.write(out);
  17.         out.close();}
  18.         catch(Exception e)
  19.         {
  20.             FileInputStream strr=new FileInputStream(FileSelect.patchin);
  21.             final HWPFDocument doc = new HWPFDocument(strr);
  22.             Range range = doc.getRange();
  23.             textField.getField();
  24.             range.insertAfter(textField.finaltxt);
  25.             final FileOutputStream out = new FileOutputStream(FileSelect.patchin);
  26.             doc.write(out);
  27.             out.close();
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement