.docファイルを読んだときに、なぜ私のテキストが整列しないのかを誰かが理解するのを手伝ってくれるかどうか疑問に思いました。これまでのコードではWordExtractorを使用していますが、フォーマットの問題があり、正しく整列されていません。これがJava1.7を使用して書かれた私のコードです。
public class Doc {
File docFile = null;
WordExtractor docExtractor = null ;
WordExtractor exprExtractor = null ;
public void read(){
docFile = new File("blue.doc");
try{
FileInputStream fis = new FileInputStream(docFile.getAbsolutePath());
HWPFDocument doc=new HWPFDocument(fis);
docExtractor = new WordExtractor(doc);
}catch(Exception e){
System.out.println(e.getMessage());
}
System.out.println(docExtractor.getText());
}
}
プログラムがドキュメントを表示する方法。
A E
I'm stuck in Folsom Prison, and time keeps draggin on.
このように表示されるはずです
A E
I'm stuck in Folsom Prison, and time keeps draggin on.