当前位置: 首页 > news >正文

网站项目接单国外产品网站

网站项目接单,国外产品网站,网页设计模板网站图片,海南在线 海南一家转自:https://www.ibm.com/developerworks/cn/java/l-java-tips/ 感谢作者发布的文章用 jacob其实 jacob 是一个 bridage#xff0c;连接 java 和 com 或者 win32 函数的一个中间件#xff0c;jacob 并不能直接抽取 word,excel 等文件#xff0c;需要自己写 dll 哦…转自:https://www.ibm.com/developerworks/cn/java/l-java-tips/     感谢作者发布的文章用 jacob其实 jacob 是一个 bridage连接 java 和 com 或者 win32 函数的一个中间件jacob 并不能直接抽取 word,excel 等文件需要自己写 dll 哦不过已经有为你写好的了就是 jacob 的作者一并提供了。下载了 jacob 并放到指定的路径之后 (dll 放到 path,jar 文件放到 classpath)就可以写你自己的抽取程序了下面是一个简单的例子importjava.io.File;import com.jacob.com.*;import com.jacob.activeX.*;/*** Title: pdf extraction* Description: email:chrismatrix.org.cn* Copyright: Matrix Copyright (c) 2003* Company: Matrix.org.cn*authorchris*version1.0,who use this example pls remain the declare*/public classFileExtracter{public static voidmain(String[] args) {ActiveXComponent component new ActiveXComponent(Word.Application);String inFile c:\\test.doc;String tpFile c:\\temp.htm;String otFile c:\\temp.xml;boolean flag false;try{component.setProperty(Visible, new Variant(false));Object wordacc component.getProperty(document ).toDispatch();Object wordfile Dispatch.invoke(wordacc,Open, Dispatch.Method,new Object[]{inFile,new Variant(false), new Variant(true)},new int[1] ).toDispatch();Dispatch.invoke(wordfile,SaveAs, Dispatch.Method,new Object[]{tpFile,new Variant(8)}, new int[1]);Variant f new Variant(false);Dispatch.call(wordfile,Close, f);flag true;}catch(Exception e) {e.printStackTrace();}finally{component.invoke(Quit, newVariant[] {});}}}用 apache 的 poi 来抽取 wordexcel。poi 是 apache 的一个项目不过就算用 poi 你可能都觉得很烦不过不要紧这里提供了更加简单的一个接口给你下载之后放到你的 classpath 就可以了下面是如何使用它的一个例子import java.io.*;import org.textmining.text.extraction.WordExtractor;/*** Title: word extraction* Description: email:chrismatrix.org.cn* Copyright: Matrix Copyright (c) 2003* Company: Matrix.org.cn* author chris* version 1.0,who use this example pls remain the declare*/public class PdfExtractor {public PdfExtractor() {}public static void main(String args[]) throws Exception{FileInputStream in new FileInputStream (c:\\a.doc);WordExtractor extractor new WordExtractor();String str extractor.extractText(in);System.out.println(the result length isstr.length());System.out.println(the result isstr);}}pdfbox- 用来抽取 pdf 文件下面是一个如何使用 pdfbox 抽取 pdf 文件的例子importorg.pdfbox.pdmodel.PDdocument importorg.pdfbox.pdfparser.PDFParser;import java.io.*;importorg.pdfbox.util.PDFTextStripper;importjava.util.Date;/*** Title: pdf extraction* Description: email:chrismatrix.org.cn* Copyright: Matrix Copyright (c) 2003* Company: Matrix.org.cn*authorchris*version1.0,who use this example pls remain the declare*/public classPdfExtracter{publicPdfExtracter(){}public String GetTextFromPdf(String filename) throwsException{String tempnull;PDdocument nbsppdfdocument null;FileInputStream isnewFileInputStream(filename);PDFParser parser newPDFParser( is );parser.parse();pdfdocument nbspparser.getPDdocument );ByteArrayOutputStream out newByteArrayOutputStream();OutputStreamWriter writer newOutputStreamWriter( out );PDFTextStripper stripper newPDFTextStripper();stripper.writeText(pdfdocument getdocument ), writer );writer.close();byte[] contents out.toByteArray();String tsnewString(contents);System.out.println(the string length iscontents.length\n);returnts;}public static voidmain(String args[]){PdfExtracter pfnewPdfExtracter();PDdocument nbsppdfdocument nbsp null;try{String tspf.GetTextFromPdf(c:\\a.pdf);System.out.println(ts);}catch(Exception e){e.printStackTrace();}}}抽取支持中文的 pdf 文件xpdfxpdf 是一个开源项目我们可以调用他的本地方法来实现抽取中文 pdf 文件。按照 readme 放好中文的 patch就可以开始写调用本地方法的 java 程序了下面是一个如何调用的例子import java.io.*;/*** Title: pdf extraction* Description: email:chrismatrix.org.cn* Copyright: Matrix Copyright (c) 2003* Company: Matrix.org.cn*authorchris*version1.0,who use this example pls remain the declare*/public classPdfWin {publicPdfWin() {}public static void main(String args[]) throwsException{String PATH_TO_XPDFC:\\Program Files\\xpdf\\pdftotext.exe;String filenamec:\\a.pdf;String[] cmd new String[] { PATH_TO_XPDF, -enc, UTF-8, -q, filename, -};Process pRuntime.getRuntime().exec(cmd);BufferedInputStream bis newBufferedInputStream(p.getInputStream());InputStreamReader reader new InputStreamReader(bis, UTF-8);StringWriter out newStringWriter();char [] buf new char[10000];intlen;while((len reader.read(buf)) 0) {//out.write(buf, 0, len);System.out.println(the length islen);}reader.close();String tsnewString(buf);System.out.println(the str ists);}}
http://www.huolong8.cn/news/242332/

相关文章:

  • 广西水利电力建设集团网站河南优化公司
  • 网站建设360山东高端网站设计
  • 能看任何网站的浏览器crm管理系统的优缺点
  • 肇庆广宁住房和城乡建设部网站做网站推广需要花多少钱
  • 建个网站多少钱app北京seo公司哪家好
  • 做直播网站软件有哪些软件网络工具app
  • 安徽网站设计与优化可以自己做课程的网站
  • 网站流量增加南宁制作营销型网站
  • 发网站视频做啥格式最好wordpress怎么使用自己的html
  • 网络推广网站建设方案公司网站建设汇报
  • 模板展示网站源码做标签网站
  • 个人网站制作说明盘锦网络推广
  • 镇江房地产网站建设网页设计代码免费
  • 免费建站源码网站添加备案
  • o2o网站建设渠道wordpress最大文件
  • 网站建设费用申请生鲜农产品网站建设
  • 建设大型门户网站网站制作公司报价
  • 网站页面一般做多大wordpress如何上传主题
  • 制作营销网站开发运营一个app大概需要多少钱
  • 刷赞网站怎么做的跨境电商自建站平台
  • 好的手机网站推荐jq网站模板
  • 企业网站建设策划书怎么写wordpress汉化主题下载地址
  • 网站建设流程步骤为需求分析企业注册在哪个网站申请
  • 石家庄网页网站制作宁波市海曙区建设局网站
  • 可视化自助建站十堰优化seo
  • 物流公司网站怎么做ui培训机构全国排名
  • 邯郸网站设计申请服装网站技术解决方案
  • 南充网站建设多少钱会网站开发想找兼职
  • 爱站网收录dw做网站 怎么做背景图片
  • 做网站首选九零后网络郑州信息港