How to convert a more than 1 doc file in a folder into text file using java.can u modify this code -


code 1 separate file:

import java.io.*;  import org.apache.poi.xwpf.extractor.xwpfwordextractor;  import org.apache.poi.xwpf.usermodel.xwpfdocument;       public class readdocfile {          public static void main(string[] args) {              file file = null;               try {                  // read doc/docx file                  file = new file("document");                  fileinputstream fis = new fileinputstream(file.getabsolutepath());                  xwpfdocument doc = new xwpfdocument(fis);                  xwpfwordextractor ex = new xwpfwordextractor(doc);                  string text = ex.gettext();                   //write text in text file                  file fil = new file("d:\\wordtotextoutput\\java1new.txt");                  writer output = new bufferedwriter(new filewriter(fil));                  output.write(text);                  output.close();              } catch (exception exep) {              }          }      }  

try following...

public void convertfiles(string folderpath){     file folder = new file(folderpath);     (file file: folder.listfiles()){         if (!file.isdirectory()){             //call existing method here `folder`         }         else{             //not sure if want handle files in subdirectories         }     } } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -