Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

³ÎÇåjavaÓïÑÔ½Ó¿ÚÓë¼Ì³ÐµÄ±¾ÖÊ

OOµÄ¾«Ë裬ÎÒÒÔΪ£¬ÊǶԶÔÏóµÄ³éÏó£¬×îÄÜÌåÏÖÕâÒ»µãµÄ¾ÍÊǽӿڡ£ÎªÊ²Ã´ÎÒÃÇÌÖÂÛÉè¼Æģʽ¶¼Ö»Õë¶Ô¾ß±¸Á˳éÏóÄÜÁ¦µÄÓïÑÔ£¨±ÈÈçc++¡¢java¡¢c#µÈ£©£¬¾ÍÊÇÒòΪÉè¼ÆģʽËùÑо¿µÄ£¬Êµ¼ÊÉϾÍÊÇÈçºÎºÏÀíµÄÈ¥³éÏó¡££¨cowboyµÄÃûÑÔÊÇ"³éÏó¾ÍÊdzéÈ¥ÏñµÄ²¿·Ö"£¬¿´ËƵ÷Ù©£¬ÊµÄËÖÁÀí£©¡£
Éè¼ÆģʽÖÐ×î»ù´¡µÄÊǹ¤³§Ä£Ê½£¨Factory£©£¬ÔÚÎÒ×î½üµÄÒ»¸öºÜ¼òµ¥µÄÓ¦ÓÃÖУ¬ÎÒÏ뾡Á¿µÄÈÃÎҵijÌÐòÄܹ»ÔÚ¶à¸öÊý¾Ý¿â¼äÒÆÖ²£¬µ±È»£¬ÕâÉæ¼°ºÜ¶àÎÊÌ⣬µ¥ÊÇÈçºÎ¼æÈݲ»Í¬DBMSµÄSQL¾ÍÈÃÈËÍ·Í´¡£ÎÒÃDz»·ÁÏÈ°ÑÎÊÌâ¼òµ¥»¯£¬Ö»¿¼ÂÇÈçºÎÁ¬½Ó²»Í¬µÄÊý¾Ý¿â¡£
¼ÙÉèÎÒÓкܶà¸öÀ࣬·Ö±ðÊÇMysql.java¡¢SQLServer.java¡¢Oracle.java¡¢DB2.java£¬ËûÃÇ·Ö±ðÁ¬½Ó²»Í¬µÄÊý¾Ý¿â£¬Í³Ò»·µ»ØÒ»¸öConnection¶ÔÏ󣬲¢ÇÒ¶¼ÓÐÒ»¸öclose·½·¨£¬ÓÃÓڹرÕÁ¬½Ó¡£Ö»ÐèÒªÕë¶ÔÄãµÄDBMS£¬Ñ¡Ôñ²»Í¬µÄÀ࣬¾Í¿ÉÒÔÓÃÁË£¬µ«ÊÇÎÒµÄÓû§Ëû»áʹÓÃʲôÊý¾Ý¿â£¿ÎÒ²»ÖªµÀ£¬ÎÒÏ£ÍûµÄÊǾ¡Á¿ÉÙµÄÐ޸ĴúÂ룬¾ÍÄÜÂú×ãËûµÄÐèÒª¡£ÎÒ¿ÉÒÔ³éÏóÈçϽӿڣº
package org.bromon.test;
public interface DB
{
¡¡¡¡java.sql.Connection openDB(String url,String user,String password);
¡¡¡¡void close();
}
Õâ¸ö½Ó¿ÚÖ»¶¨ÒåÁ½¸ö·½·¨£¬Ã»ÓÐÈκÎÓÐʵ¼ÊÒâÒåµÄ´úÂ룬¾ßÌåµÄ´úÂëÓÉʵ×÷Õâ¸ö½Ó¿ÚµÄÀàÀ´¸ø³ö£¬±ÈÈçMysql.java£º
Package org.bromon.test;
import java.sql.*;
public class Mysql implements DB
{
¡¡¡¡private String url="jdbc:mysql:localhost:3306/test";
¡¡¡¡private String user="root";
¡¡¡¡private String password="";
¡¡¡¡private Connection conn;
¡¡¡¡public Connection openDB(url,user,password)
¡¡¡¡{
¡¡¡¡¡¡¡¡//Á¬½ÓÊý¾Ý¿âµÄ´úÂë
¡¡¡¡}
¡¡¡¡public void close()
¡¡¡¡{
¡¡¡¡¡¡¡¡//¹Ø±ÕÊý¾Ý¿â
¡¡¡¡}
}
ÀàËƵĵ±È»»¹ÓÐOracle.javaµÈµÈ£¬½Ó¿ÚDB¸øÕâЩÀà¹éÁ˸öÀ࣬ÔÚÓ¦ÓóÌÐòÖÐÎÒÃÇÕâÑù¶¨Òå¶ÔÏó£º
org.bromon.test.DB myDB;
ʹÓÃmyDBÀ´²Ù×÷Êý¾Ý¿â£¬¾Í¿ÉÒÔ²»ÓùÜʵ¼ÊÉÏÎÒËùʹÓõÄÊÇÄĸöÀ࣬Õâ¾ÍÊÇËùνµÄ"¿ª-±Õ"Ô­Ôò¡£µ«ÊÇÎÊÌâÔÚÓÚ½Ó¿ÚÊDz»ÄÜʵÀý»¯µÄ£¬myDB=new DB()£¬ÕâÑùµÄ´úÂëÊǾø¶Ô´íÎóµÄ£¬ÎÒÃÇÖ»ÄÜmyDB=new Mysql()»òÕßmyDB=new Oracle()¡£Âé·³ÁË£¬ÎÒ»¹ÊÇÐèÒªÖ¸¶¨¾ßÌåʵÀý»¯µÄÊÇÄĸöÀ࣬ÓÃÁ˽ӿڸúûÓÃÒ»Ñù¡£ËùÒÔÎÒÃÇÐèÒªÒ»¸ö¹¤³§£º
package org.bromon.test;
public class DBFactory
{
¡¡¡¡public static DB Connection getConn()
¡¡¡¡{
¡¡¡¡¡¡¡¡Return(new Mysql());
¡¡¡¡}
}
ËùÒÔʵ


Ïà¹ØÎĵµ£º

java µ÷ÓÃϵͳ¿ÉÖ´ÐгÌÐò

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RunDosCommand {
  public static void main(String[] args) throws IOException {
      String cmd = "ipconfig";
      R ......

JavaÓÅ»¯²ßÂÔ£¨Ò»£©£ºµ×²ãÓÅ»¯

By ³å³öÓîÖæ from °Á¶û¿Æ¼¼(www.hour41.com)
ʱ¼ä£º2006-11-17
×¢£º×ªÔØÇë×¢Ã÷×÷Õߺ͵¥Î»¡£
       JavaÓïÑÔ±ê×¼´Ó1996Äê·¢²¼µÚÒ»°æ£¬µ½2000Äê·¢²¼µÚ¶þ°æ£¬ÔÙµ½2004Äê·¢²¼µÚÈý°æ£¬javaÓïÑÔÒѾ­¾­¹ýÁË3´Î´óµÄÀ©³äºÍ¸Ä½ø¡£¹¦ÄÜÊÇÔ½À´Ô½¶à£¬²Ù×÷ÊÇÔ½À´Ô½¸´ÔÓ¡£ÏÔÈ»£¬ÐÔÄÜÎÊÌâÒ²¾ÍÔ½À´Ô½Í» ......

ÎÒÓÃjava±»±ÉÊÓÁË

      ÎÒÔÚ¼ÆËã»úÐÐÒµºÍÎÒµÄͼ±êÒ»Ñù»¹Ö»ÊÇÒ»¸öСº¢£¬µ±ÎÒÔÚÄÃϼÆËã»ú4¼¶£¨Èí¼þ²âÊÔ¹¤³Ìʦ£©ºÍ±àдÁ˲»ÉÙµÄͦcoolµÄ³ÌÐòÖ®ºó£¬¾õµÃ
×Ô¼ºË®Æ½²»Àµ¹þ¡£½á¹û¸Õ¿çÈëÒ»¸ö´ó¹«Ë¾ÊµÏ°µÄʱºò£¬ÎÒ¿´µ½ÎÒµÄÄǸöÏîÄ¿£¬ºÜ¿ìÎÒ±à³ÌµÄ˼άÓÖÔÚÌø¶¯£¬¿É“ÀÏ´ó”À´ÁËÒ»¾äc/c++ʵÏÖ
£¬ÎҾͷ·ðµ½ÁËÒ»¸ ......

Java²Ù×÷ExcelµÄ¹¤¾ßÀà

public class ExcelUtil {
/*
* ¸ù¾ÝExcelÎļþ·¾¶ºÍ±íµ¥Ãû³Æ£¬Ò»´Î²éÕÒ´Ë±íµ¥µÄËùÓмǼ*/
public static String[][] getContentByName(String sourcePath,String sheetName){
String[][] strArray = null;
try {

InputStream is = new FileInputStream(sourcePath);
Workbook wb = Workbook.get ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ