<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-153  評論-235  文章-19  trackbacks-0
     
            加style="cursor:hand" ,firefox無效。
    posted @ 2008-03-16 12:56 流浪汗 閱讀(4159) | 評論 (2)編輯 收藏
         收集于網(wǎng)絡(luò),自已小改動下。
    有DrawImage(ImgD, width, height) 調(diào)整圖像比例的javascript函數(shù)。

    <script language="javascript">
    <!--

    var flag=false;
    function DrawImage(ImgD, width, height){
    var image=new Image();
    var iwidth = width;
    var iheight = height;
    image.src
    =ImgD.src;
    if(image.width>0 && image.height>0){
    flag
    =true;
    if(image.width/image.height>= iwidth/iheight){
    if(image.width>iwidth){
    ImgD.width
    =iwidth;
    ImgD.height
    =(image.height*iwidth)/image.width;
    }
    else{
    ImgD.width
    =image.width;
    ImgD.height
    =image.height;
    }
    ImgD.alt
    =image.width+""+image.height;
    }
    else{
    if(image.height>iheight){
    ImgD.height
    =iheight;
    ImgD.width
    =(image.width*iheight)/image.height;
    }
    else{
    ImgD.width
    =image.width;
    ImgD.height
    =image.height;
    }
    ImgD.alt
    =image.width+""+image.height;
    }
    }
    }
    //-->
    </script>
    <style type="text/css">
    .pic_size 
    {border:1px solid #CCCCCC;width:240px;height:200px;margin-top:5px;background:#FFF;}
    </style>
    <div class="pic_size"><table width="100%" height="100%"><tr><td style="text-align: center;vertical-align: middle;"><img src="my.jpg" onload = "DrawImage(this,240,200)"></td></tr></table></div>
    posted @ 2008-03-16 12:43 流浪汗 閱讀(380) | 評論 (0)編輯 收藏
        在HTML內(nèi)頭部加以下內(nèi)容。

    <link rel="shortcut icon" href="/images/my.ico" type="image/x-icon" />
    posted @ 2008-03-16 12:32 流浪汗 閱讀(354) | 評論 (0)編輯 收藏
        以前想用循環(huán)來System.in (或是其它輸入方式老是達(dá)不預(yù)想的效果,第一次輸入后回車,不會接收下一次用戶的輸入)。后來才發(fā)現(xiàn)readline() != null才能達(dá)到效果。

    package net.blogjava.chenlb;

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    /**
     * 重復(fù)接收用戶輸入一行命令
     * 
    @author chenlb 2008-3-11 下午09:24:50
     
    */
    public class UserInput {

        
        
    public static void main(String[] args) throws IOException {
            System.out.println(
    "說明: 輸入QUIT退出");
            System.out.print(
    "\ninput>");
            String inputStr 
    = null;
            BufferedReader br 
    = new BufferedReader(new InputStreamReader(System.in));
            
    while((inputStr = br.readLine()) != null) {
                
    if(inputStr.equals("QUIT")) {
                    System.exit(
    0);
                }
                System.out.println(
    "你輸入的是: "+inputStr);    //處理你的邏輯
                System.out.print("\ninput>");
            }

        }

    }
    posted @ 2008-03-11 21:49 流浪汗 閱讀(982) | 評論 (0)編輯 收藏
         最近看下Lucene的東西,把它寫下來可以看下。Lucene結(jié)構(gòu)和工作原理我就不說了,網(wǎng)上好多。

    我的環(huán)境是Lucene2.0
    寫一個(gè)簡單使用Lucene的示例。此類首創(chuàng)建索引,然后顯示索引文檔的情況,最后搜索(只在content找,和在title或content里找)。

    package net.blogjava.chenlb.lucene;

    import org.apache.lucene.analysis.standard.StandardAnalyzer;
    import org.apache.lucene.document.Document;
    import org.apache.lucene.document.Field;
    import org.apache.lucene.index.IndexReader;
    import org.apache.lucene.index.IndexWriter;
    import org.apache.lucene.queryParser.MultiFieldQueryParser;
    import org.apache.lucene.queryParser.QueryParser;
    import org.apache.lucene.search.BooleanClause;
    import org.apache.lucene.search.Hits;
    import org.apache.lucene.search.IndexSearcher;
    import org.apache.lucene.search.Query;

    /**
     * Lucene簡單使用
     * 
    @author chenlb 2008-3-8 下午11:42:55
     
    */
    public class LuceneUse {

        
    public static void main(String[] args) throws Exception {
            LuceneUse liu 
    = new LuceneUse();
            
    //索引
            IndexWriter iw = new IndexWriter("index"new StandardAnalyzer(), true);
            
    //添加要索引的Lucene文檔
            Document doc = liu.createDoc("Lucene創(chuàng)建索引示例""chenlb""2008-03-08""Lucene索引的內(nèi)容在這里,這些內(nèi)容不被存儲.");
            iw.addDocument(doc);
            
            doc 
    = liu.createDoc("文檔2""bin""2007-10-03""這是索引的另一個(gè)文檔");
            iw.addDocument(doc);
            
            doc 
    = liu.createDoc("學(xué)習(xí)內(nèi)容""chenlb""2008-3-3""要努力奮斗,祝網(wǎng)友們天天快樂");
            iw.addDocument(doc);
            
            iw.optimize();    
    //優(yōu)化
            iw.close();
            
            
    //
            System.out.println("===========索引文檔內(nèi)容=============");
            IndexReader reader 
    = IndexReader.open("index");
            
    for(int i=0; i<reader.numDocs(); i++) {
                Document d 
    = reader.document(i);
                liu.printDoc(d);
            }
            
            System.out.println(
    "===========以下是單域查找'天天'結(jié)果============");
            
    //單域搜索
            IndexSearcher searcher = new IndexSearcher("index");
            QueryParser parser 
    = new QueryParser("content"new StandardAnalyzer());
            Query q 
    = parser.parse("天天"); 
            
            
    long start = System.currentTimeMillis();
            Hits hits 
    = searcher.search(q);
            
    long end = System.currentTimeMillis();
            
    for(int i=0; i<hits.length(); i++) {
                liu.printDoc(hits.doc(i));
            }
            System.out.println(
    "共找到: "+hits.length()+" 個(gè)文檔,花了:"+(end-start)+"ms");
            
            
    //多域搜索
            System.out.println("===========以下多域是查找'內(nèi)容'結(jié)果============");
            
    //從title或content找
            q = MultiFieldQueryParser.parse("內(nèi)容"new String[] {"title""content"}, new BooleanClause.Occur[] {BooleanClause.Occur.SHOULD, BooleanClause.Occur.SHOULD}, new StandardAnalyzer());
            start 
    = System.currentTimeMillis();
            hits 
    = searcher.search(q);
            end 
    = System.currentTimeMillis();
            
    for(int i=0; i<hits.length(); i++) {
                liu.printDoc(hits.doc(i));
            }
            System.out.println(
    "共找到: "+hits.length()+" 個(gè)文檔,花了:"+(end-start)+"ms");
        }
        
        
    /**
         * 顯示文檔內(nèi)容
         
    */
        
    private void printDoc(Document d) {
            System.out.println(
    "標(biāo)題: "+d.get("title")+", 作者: "+d.get("author")+", 日期: "+d.get("date")+", 內(nèi)容: "+d.get("content"));
        }
        
        
    /**
         * 創(chuàng)建一個(gè)Lucene文檔
         
    */
        
    private Document createDoc(String title, String author, String date, String content) {
            Document doc 
    = new Document();
            doc.add(
    new Field("title", title, Field.Store.YES, Field.Index.TOKENIZED));
            doc.add(
    new Field("author", author, Field.Store.YES, Field.Index.NO));
            doc.add(
    new Field("date", date, Field.Store.YES, Field.Index.NO));
            doc.add(
    new Field("content", content, Field.Store.YES, Field.Index.TOKENIZED));
            
    return doc;
        }
    }
    posted @ 2008-03-09 00:47 流浪汗 閱讀(979) | 評論 (0)編輯 收藏
        這幾天想用Java讀富文檔。用javax.swing.text和javax.swing.text.rtf包中的類讀RTF文檔時(shí)出現(xiàn)中文亂碼問題(出現(xiàn)?號)。
        幸好找到 ANGEL SKY 的博客。用ISO8859_1編碼轉(zhuǎn)換。

    代碼片斷:
    String bodyText = null;
            DefaultStyledDocument styledDoc 
    = new DefaultStyledDocument();    //javax.swing.text.Document的一個(gè)實(shí)例
            try {
                InputStream is 
    = new FileInputStream(new File("data/java.swing.text讀RTF文檔測試.rtf"));
                
    new RTFEditorKit().read(is, styledDoc, 0);
                bodyText 
    = new String(styledDoc.getText(0, styledDoc.getLength()).getBytes("ISO8859_1"));    //提取文本
            } catch (IOException e) {
                
    throw new DocumentHandlerException("不能從RTF中摘錄文本!", e);
            } 
    catch (BadLocationException e) {
                
    throw new DocumentHandlerException("不能從RTF中摘錄文本!", e);
            }
            System.out.println(bodyText);
    posted @ 2008-02-01 17:05 流浪汗 閱讀(2284) | 評論 (0)編輯 收藏
        這學(xué)期,應(yīng)聘的時(shí)候有一些是線程相關(guān)的,雖然自己對線程編程有點(diǎn)概念,但沒有寫過經(jīng)典的例子。放假了有點(diǎn)時(shí)候,就想寫多線程的例子。

        筆試的題目類似地:一個(gè)生產(chǎn)者一次生產(chǎn)10個(gè),滿了后通知消費(fèi)者,然后等待。一個(gè)消費(fèi)者產(chǎn)品有滿了就消費(fèi)。到空時(shí)通知生產(chǎn)者,然后等待。

        那時(shí)對等待/通知機(jī)制沒怎么寫過,那次筆試應(yīng)該寫的大概對(想法對),但寫的wait()和notifyAll()的位置不對。現(xiàn)在有時(shí)間就寫了這個(gè)例子。
        描述:生產(chǎn)者一次生產(chǎn)N個(gè)產(chǎn)品,池中達(dá)到M就等待,通知等待的消費(fèi)者。消費(fèi)者有產(chǎn)品就消費(fèi),到?jīng)]有時(shí)就通知生產(chǎn)者,然后等待。

    1.生產(chǎn)者:
    package net.blogjava.chenlb.multithreaded;

    import java.util.List;

    /**
     * 
    @author chenlb
     * 
     * 生產(chǎn)者.<br/>
     * 默認(rèn)產(chǎn)品池大小M=20,產(chǎn)品梯階大小N=5.在生產(chǎn)過程中,池的大小會超過20,但池中最大應(yīng)該是M+N-1.
     
    */
    public class Producer implements Runnable {

        
    /**
         * 池默認(rèn)大小
         
    */
        
    public static final int DEFALUT_SIZE = 20;
        
    /**
         * 默認(rèn)一次生產(chǎn)的數(shù)量
         
    */
        
    public static final int DEFALUT_STEP_SIZE = 5;
        
        
    private static int PRODUCER_ID = 0;    //生產(chǎn)者號
        
        
    private List<Product> pool = null;
        
    private int size = DEFALUT_SIZE;
        
    private int stepSize = DEFALUT_STEP_SIZE;
        
        
    private String name = "Producer_"+(++PRODUCER_ID);    //生產(chǎn)者名
        
        
    private boolean isRun = true;
        
        
    /**
         * 默認(rèn)產(chǎn)品池大小20, 默認(rèn)產(chǎn)品增長梯階大小5
         
    */
        
    public Producer(List<Product> pool) {
            
    this.pool = pool;
        }

        
    /**
         * 
    @param pool
         * 
    @param size 池大小
         
    */
        
    public Producer(List<Product> pool, int size) {
            
    this.pool = pool;
            
    this.size = size;
        }
        
        
        
    /**
         * 
    @param pool
         * 
    @param size 池大小
         * 
    @param stepSize 一次生產(chǎn)多少
         
    */
        
    public Producer(List<Product> pool, int size, int stepSize) {
            
    this.pool = pool;
            
    this.size = size;
            
    this.stepSize = stepSize;
        }

        
    public void run() {
            
    // TODO 生產(chǎn)者線程
            
    //int pi = 0;
            while(isRun) {//&& pi<10
                
    //pi++;
                synchronized (pool) {    //同步產(chǎn)品池
                    if(pool.size() >= size) {
                        
    try {
                            System.out.println(name
    +" 等待!");
                            pool.wait();    
    //同步什么就等待什么,否則拋出java.lang.IllegalMonitorStateException
                        } catch (InterruptedException e) {
                            isRun 
    = false;
                            System.out.println(name
    +" thread interrupt!");                    
                        }
                    } 
    else {
                        
                        
    for(int i=0; i<stepSize; i++) {    //一次生產(chǎn)stepSize個(gè)產(chǎn)品
                            pool.add(product());    //生產(chǎn)產(chǎn)品
                        }
                        System.out.println(
    "產(chǎn)品池中有: "+pool.size());
                        pool.notifyAll();    
    //通知等待的線程(主要用來通知消費(fèi)者, 但生產(chǎn)者線程也會通知到)
                    }
                }
                
                
    try {
                    System.out.println(name
    +" 休息1秒!");
                    Thread.sleep(
    1000);    //調(diào)試用
                } catch (InterruptedException e) {
                    System.out.println(name
    +" sleep 1s thread interrupt");
                }
            }
            System.out.println(name
    +" end! pool size: "+pool.size());
        }

        
    private static int P_ID = 0;
        
    /**
         * 生產(chǎn)產(chǎn)品
         * 
    @return 產(chǎn)品
         
    */
        
    private Product product() {
            String name 
    = "product_"+(++P_ID);
            System.out.println(
    this.name+" 生產(chǎn)了: "+name);
            
    return new Production(name);
        }
        
    }


    2.消費(fèi)者:

    package net.blogjava.chenlb.multithreaded;

    import java.util.List;

    /**
     * 
    @author chenlb
     * 
     * 消費(fèi)者
     
    */
    public class Consumer implements Runnable {

        
    private static int C_ID = 0;    //消費(fèi)者ID
        
        
    private List<Product> pool = null;
        
    private String name = "Consumer_"+(++C_ID);
        
    private boolean isRun = true;
        
    public Consumer(List<Product> pool) {
            
    this.pool = pool;
        }
        
        
    public void run() {
            
    // TODO 消費(fèi)者線程
            
    //int pi = 0;
            while(isRun) {//&& pi<10
                
    //pi++;
                synchronized (pool) {
                    
    if(pool.size() < 1) {
                        
    try {
                            System.out.println(name
    +" 等待!");
                            pool.notifyAll();    
    //通知線程(主要是生產(chǎn)者,但也會通知到生產(chǎn)者線程)
                            pool.wait();
                        } 
    catch (InterruptedException e) {
                            isRun 
    = false;
                            System.out.println(name
    +" thread interrupt!");
                        }
                    } 
    else {
                        Product p 
    = pool.remove(0);    //消費(fèi)
                        printProduct(p);
                        
                    }
                }
                
    try {
                    Thread.sleep(
    1000);    //調(diào)試用
                } catch (InterruptedException e) {
                    
                    System.out.println(name
    +" sleep 1s thread interrupt");
                }
            }
            System.out.println(name
    +" end! pool size: "+pool.size());
        }

        
    private void printProduct(Product p) {
            System.out.println(name
    +" 消費(fèi)了: "+p.getName());
        }
    }


    3.Demo
    package net.blogjava.chenlb.multithreaded;

    import java.util.LinkedList;
    import java.util.List;

    /**
     * 
    @author chenlb
     *
     
    */
    public class Sale {

        
        
    public static void main(String[] args) {
            
    //鏈表產(chǎn)品池
            List<Product> pool = new LinkedList<Product>();
            
    //兩個(gè)生產(chǎn)者
            Producer p1 = new Producer(pool);
            Producer p2 
    = new Producer(pool);
            
            Thread tp1 
    = new Thread(p1);
            Thread tp2 
    = new Thread(p2);
            
            tp1.start();
            tp2.start();
            
            
    //兩個(gè)消費(fèi)者
            Consumer c1 = new Consumer(pool);
            Consumer c2 
    = new Consumer(pool);
            
            Thread tc1 
    = new Thread(c1);
            Thread tc2 
    = new Thread(c2);
            
            tc1.start();
            tc2.start();
            
            

        }

    }

    注意:等待時(shí)候要用pool.wait()因?yàn)橥降氖莗ool。否則會拋出java.lang.IllegalMonitorStateException

    ^_^

    代碼下載
    posted @ 2008-01-24 11:36 流浪汗 閱讀(547) | 評論 (0)編輯 收藏


    1.聚合關(guān)系也稱"has-a"關(guān)系,組合關(guān)系也稱"contains-a"關(guān)系

    2.聚合關(guān)系表示事物的整體/部分關(guān)系的較弱情況,組合關(guān)系表示事物的整體/部分關(guān)系的較強(qiáng)的情況.

    3.在聚合關(guān)系中,代表部分事物的可以屬于多個(gè)聚合對象,可以為多個(gè)聚合對象共享,而且可以隨時(shí)改變它所從屬的聚合對象.代表部分事物的對象與代表聚合事物對象的生存期無關(guān),一旦刪除了它的一個(gè)聚合對象,不一定也就隨即刪除代表部分事物的對象.在組合關(guān)系中,代表整體事物的對象負(fù)責(zé)創(chuàng)建和刪除代表部分事物的對象,代表部分事物只屬于一個(gè)組合對象.一旦刪除了組合對象,也就隨即刪除了相應(yīng)的代表部分事物的對象.
    posted @ 2008-01-15 22:02 流浪汗 閱讀(2658) | 評論 (0)編輯 收藏
          oracle 用戶SYS 和 SYSTEM的默認(rèn)口令:TIGER
    posted @ 2008-01-03 15:10 流浪汗 閱讀(1502) | 評論 (0)編輯 收藏
    .什么是pv
      PV(page view),即頁面瀏覽量,或點(diǎn)擊量;通常是衡量一個(gè)網(wǎng)絡(luò)新聞?lì)l道或網(wǎng)站甚至一條網(wǎng)絡(luò)新聞的主要指標(biāo)。

      高手對pv的解釋是,一個(gè)訪問者在24小時(shí)(0點(diǎn)到24點(diǎn))內(nèi)到底看了你網(wǎng)站幾個(gè)頁面。這里需要強(qiáng)調(diào):同一個(gè)人瀏覽你網(wǎng)站同一個(gè)頁面,不重復(fù)計(jì)算pv量,點(diǎn)100次也算1次。說白了,pv就是一個(gè)訪問者打開了你的幾個(gè)頁面。

      PV之于網(wǎng)站,就像收視率之于電視,從某種程度上已成為投資者衡量商業(yè)網(wǎng)站表現(xiàn)的最重要尺度。

      pv的計(jì)算:當(dāng)一個(gè)訪問著訪問的時(shí)候,記錄他所訪問的頁面和對應(yīng)的IP,然后確定這個(gè)IP今天訪問了這個(gè)頁面沒有。如果你的網(wǎng)站到了23點(diǎn),單純IP有60萬條的話,每個(gè)訪問者平均訪問了3個(gè)頁面,那么pv表的記錄就要有180萬條。

        有一個(gè)可以隨時(shí)查看PV流量以及你的網(wǎng)站世界排名的工具alexa工具條,安裝吧!網(wǎng)編們一定要安裝這個(gè)。

      .什么是uv
    uv(unique visitor),指訪問某個(gè)站點(diǎn)或點(diǎn)擊某條新聞的不同IP地址的人數(shù)。

      在同一天內(nèi),uv只記錄第一次進(jìn)入網(wǎng)站的具有獨(dú)立IP的訪問者,在同一天內(nèi)再次訪問該網(wǎng)站則不計(jì)數(shù)。獨(dú)立IP訪問者提供了一定時(shí)間內(nèi)不同觀眾數(shù)量的統(tǒng)計(jì)指標(biāo),而沒有反應(yīng)出網(wǎng)站的全面活動。

      .什么是PR值
    PR值,即PageRank,網(wǎng)頁的級別技術(shù)。取自Google的創(chuàng)始人Larry Page,它是Google排名運(yùn)算法則(排名公式)的一部分,用來標(biāo)識網(wǎng)頁的等級/重要性。級別從1到10級,10級為滿分。PR值越高說明該網(wǎng)頁越受歡迎(越重要)。

      例如:一個(gè)PR值為1的網(wǎng)站表明這個(gè)網(wǎng)站不太具有流行度,而PR值為7到10則表明這個(gè)網(wǎng)站非常受歡迎(或者說極其重要)。

      我們可以這樣說:一個(gè)網(wǎng)站的外部鏈接數(shù)越多其PR值就越高;外部鏈接站點(diǎn)的級別越高(假如Macromedia的網(wǎng)站鏈到你的網(wǎng)站上),網(wǎng)站的PR值就越高。例如:如果ABC.COM網(wǎng)站上有一個(gè)XYZ.COM網(wǎng)站的鏈接,那為ABC.COM網(wǎng)站必須提供一些較好的網(wǎng)站內(nèi)容,從而Google會把來自XYZ.COM的鏈接作為它對ABC.COM網(wǎng)站投的一票。

      你可以下載和安裝Google工具條來檢查你的網(wǎng)站級別(PR值)。  


    詳細(xì)看: http://www.skynuo.com/faq_qc7.htm

    posted @ 2007-12-31 13:51 流浪汗 閱讀(385) | 評論 (0)編輯 收藏
    僅列出標(biāo)題
    共16頁: First 上一頁 2 3 4 5 6 7 8 9 10 下一頁 Last 
    主站蜘蛛池模板: 在线观着免费观看国产黄| xx视频在线永久免费观看| a毛片免费全部在线播放**| 最近更新免费中文字幕大全| 精品免费tv久久久久久久| 日韩在线播放全免费| 精品久久久久久久免费加勒比| 亚洲欧洲日产国码高潮αv| 亚洲精品无码Av人在线观看国产 | 国产一级淫片免费播放| 国产精品亚洲mnbav网站 | 在线播放亚洲精品| 中国精品一级毛片免费播放| 99久久99久久精品免费观看| 成人免费无码大片A毛片抽搐| 亚洲精品成人区在线观看| 久久久久亚洲精品成人网小说 | 亚洲中文字幕无码久久| 午夜免费国产体验区免费的| 男人都懂www深夜免费网站| 国产免费不卡v片在线观看| 亚洲成年人啊啊aa在线观看| 亚洲视频国产精品| 美女尿口扒开图片免费| 亚洲视频在线观看免费| 国产免费牲交视频| 午夜亚洲AV日韩AV无码大全| 亚洲欧美日韩一区二区三区在线| 精品一区二区三区高清免费观看| 2021国产精品成人免费视频| 亚洲黄片手机免费观看| 亚洲最大在线观看| igao激情在线视频免费| 一本岛高清v不卡免费一三区| 亚洲免费日韩无码系列| 亚洲人成电影青青在线播放| 91免费在线视频| 成人免费777777| 亚洲AV成人片色在线观看 | 菠萝菠萝蜜在线免费视频| 99re在线免费视频|