Java¶ÁÈ¡PDF,DocµÄ·½·¨
ºÜ¶àÈËÎʵ½ÈçºÎ³éÈ¡word£¬excel£¬pdf°¢¡£ÕâÀïÎÒ×ܽáһϳéÈ¡word,pdfµÄ
¼¸ÖÖ·½·¨¡£
1¡£ÓÃjacob.
ÆäʵjacobÊÇÒ»¸öbridage£¬Á¬½ÓjavaºÍcom»òÕßwin32º¯ÊýµÄÒ»¸öÖмä¼þ£¬jacob²¢²»ÄÜÖ±½Ó³éÈ¡word,excelµÈÎļþ£¬ÐèÒª×Ô¼ºÐ´dllŶ£¬²»¹ýÒѾÓÐΪÄãдºÃµÄÁË£¬¾ÍÊÇjacobµÄ×÷ÕßÒ»²¢ÌṩÁË¡£
jacobÏÂÔØ£ºhttp://www.matrix.org.cn/down_view.asp?id=13
ÏÂÔØÁËjacob²¢·Åµ½Ö¸¶¨µÄ·¾¶Ö®ºó(dll·Åµ½path,jarÎļþ·Åµ½classpath)£¬¾Í¿ÉÒÔдÄã×Ô¼ºµÄ³éÈ¡³ÌÐòÁË£¬ÏÂÃæÊÇÒ»¸öÀý×Ó£º
import java.io.File;
import com.jacob.com.*;
import com.jacob.activeX.*;
public class FileExtracter{
public static void main(String[] args) {
ActiveXComponent app = new ActiveXComponent("Word.Application");
String inFile = "c:\\test.doc";
String tpFile = "c:\\temp.htm";
String otFile = "c:\\temp.xml";
boolean flag = false;
try {
app.setProperty("Visible", new Variant(false));
Object docs = app.getProperty("Documents").toDispatch();
Object doc = Dispatch.invoke(docs,"Open", Dispatch.Method, new Object[]{inFile,new Variant(false), new Variant(true)}, new int[1]).toDispatch();
Dispatch.invoke(doc,"SaveAs", Dispatch.Method, new Object[]{tpFile,new Variant(8)}, new int[1]);
Variant f = new Variant(false);
Dispatch.call(doc, "Close", f);
flag = true;
} catch (Exception e) {
e.printStackTrace();
} finally {
app.invoke("Quit", new Variant[] {});
}
}
}
2¡£ÓÃapacheµÄpoiÀ´³éÈ¡word£¬excel¡£
poiÊÇapacheµÄÒ»¸öÏîÄ¿£¬²»¹ý¾ÍËãÓÃpoiÄã¿ÉÄܶ¼¾õµÃºÜ·³£¬²»¹ý²»Òª½ô£¬ÕâÀïÌṩÁ˸ü¼Ó¼òµ¥µÄÒ»¸ö½Ó¿Ú¸øÄ㣺
ÏÂÔؾ¹ý·â×°ºóµÄpoi°ü£ºhttp://www.matrix.org.cn/down_view.asp?id=14
ÏÂÔØÖ®ºó£¬·Åµ½ÄãµÄclasspath¾Í¿ÉÒÔÁË£¬ÏÂÃæÊÇÈçºÎʹÓÃËüµÄÒ»¸öÀý×Ó£º
import java.io.*;
import org.textmining.text.extraction.WordExtractor;
/**
* <p>Title: pdf extraction</p>
* <p>Description: email:chris@matrix.org.cn</p>
* <p>Copyright: Matrix Copyright (c) 2003</p>
* <p>Company: Matrix.org.cn</p>
* @author chris
* @version 1.0,who use this example pls remain the declare
*/
Ïà¹ØÎĵµ£º
package debug;import java.io.*;import java.lang.Thread;class MyThread extends Thread{ public int x = 0; public void run(){ System.out.println(++x); }}class R implements Runnable{ private int x = 0; public void run(){ System.out.printl ......
jdkÌṩÁËZipÏà¹ØµÄÀà·½±ãµÄʵÏÖѹËõºÍ½âѹËõ¡£Ê¹Ó÷½·¨ºÜ¼òµ¥¡£Ï±߷ֱðÊÇѹËõºÍ½âѹËõµÄ¼òµ¥ÊÂÀý
1£¬Ñ¹ËõµÄ
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import ......
×î½üÐèÒªÖÆ×÷java desktop applicationµÄ°²×°³ÌÐò¡£
ºÃ²»ÈÝÒ×ÔÚÍøÉÏdownÁ˸öinstallanywhere9°²×°²¢Æƽ⣬ ÓÃÆðÀ´»¹Í¦Ë³Àû£¬¹¦ÄܱȽÏÇ¿´ó£¬Ðí¶àµØ·½¿ÉÒÔ¶¨ÖÆ£¬µ±È»×ö³öÀ´µÄ³ÌÐòÔÚ°²×°Ê±Ò²Ëæ´¦¿É¼ûinstallanywhereµÄÉíÓ°£¬ÉÌÒµÈí¼þÂû°ì·¨¡£
ºóÀ´³ÌÐòÔÚÔËÐйý³ÌÖУ¬·¢ÏÖ×ÔÒÔΪÉèÖýøÈ¥ÁËjava desktop applicationµÄjreµ ......
1. MySQL(http://www.mysql.com)mm.mysql-2.0.2-bin.jar ;
Class.forName( "org.gjt.mm.mysql.Driver" );
cn = DriverManager.getConnection( "jdbc:mysql://MyDbComputerNameOrIP:3306/myDatabaseName", sUsr, sPwd );
2. PostgreSQL(http://www.de.postgresql.org)pgjdbc2.jar ;
Class.forName( "org.postgresql. ......