Home > Back-end > Java download the word from the server to the web client, change the word, will modify the word docu
Java download the word from the server to the web client, change the word, will modify the word docu
Time:11-03
Java download the word from the server to the web client, change the word, will modify the word documents uploaded to the server again, replace files, before pursuing big brand how to write!!!!!! I've got to save is to modify the code to the local, don't want to save to a local! It is according to the word document to bookmark location insertion picture
//eapFileUrl download files from the server url, path, gongyi of query to file id URL the URL=new URL (download file server URL + "download/? ID="+ document ID); HttpURLConnection conn=(HttpURLConnection) url. OpenConnection (); //set super time for 3 seconds Conn. SetConnectTimeout (3 * 1000); //to prevent blocking fetching and returns a 403 error Conn. SetRequestProperty (" the user-agent ", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT. DigExt) ");
//get the input stream InputStream InputStream=conn. GetInputStream (); //get the data file WordprocessingMLPackage wPackage=WordprocessingMLPackage. Load (inputStream); //to extract text MainDocumentPart MainDocumentPart=wPackage. GetMainDocumentPart (); The Document wmlDoc=(Document) mainDocumentPart. GetJaxbElement (); Body Body=wmlDoc. GetBody (); //all paragraphs in extraction of text List