将字符串写入粗体和下划线样式的文件

Nik*_*dze 3 java ms-word

我有WriteFileWriteToFile写入Stringword文档的方法的类.

  WriteFile data=new WriteFile("C:/test3.doc",true);  
  data.writeToFile(user.saxeli+" "+user.gvari+" "+user.asaki+" "+user.swori);
Run Code Online (Sandbox Code Playgroud)

如何String用粗体和下划线样式写"test3.doc"?

这是WriteFile类:

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class WriteFile {

 private String path;
 private boolean append=true;
 public WriteFile(String path,boolean append){
  this.path=path; this.append=append;
}
 public void writeToFile(String text) throws IOException{
  FileWriter write=new FileWriter(path,append);
  PrintWriter print_line= new PrintWriter(write);
  print_line.printf("%s"+"%n", text);
  print_line.close();
}
}
Run Code Online (Sandbox Code Playgroud)

ljg*_*jgw 6

看看Apache POI.该库可以写入Microsoft Word文件并使用粗体和下划线(字体)样式.