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

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

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

    鄧華

    BlogJava 聯(lián)系 聚合 管理
      48 Posts :: 0 Stories :: 149 Comments :: 0 Trackbacks

    #

    為了解決linux上的中方問(wèn)題,今天在google上搜索了一圈, 發(fā)現(xiàn)都是需要在linux的全局加入字體,在java中引用才能解決。不死心,因?yàn)樵谠瓉?lái)的PHP程序中可以直接使用TTF字體,在JAVA類庫(kù)中有了發(fā)現(xiàn)。

    呵呵,不多寫(xiě)了,直接帖上測(cè)試原碼。

     

    import java.io.File;
    import java.awt.*;

    public class testFont {

      private static String fontpath = "D:\\work\\WORK\\fonts\\";
      private static java.io.File file = new java.io.File(fontpath + "simhei.ttf");

      public testFont() {
      }

      public static void main(String args[]) {

        if (!file.exists()) {
          System.out.println("file not found");
          return;
        }
        try {
          java.io.FileInputStream fi = new java.io.FileInputStream(file);
          java.io.BufferedInputStream fb = new java.io.BufferedInputStream(fi);
          Font nf = Font.createFont(Font.TRUETYPE_FONT, fb);

          nf = nf.deriveFont(Font.BOLD, 10);
          System.out.println(nf.getFontName());
          System.out.println(nf.getSize());
        }
        catch (Exception e) {
          System.out.println(e.getMessage());
        }
      }

    }

     

    posted @ 2006-03-16 11:58 鄧華的碎碎念 閱讀(733) | 評(píng)論 (0)編輯 收藏

    如何獲得一個(gè)字符的寬度和高度? 
    來(lái)源:ChinaITLab.com
    2003-9-30 16:22:00
    ChinaITLab新標(biāo)志正式啟動(dòng),新鮮出爐大激賞!
     
     
      如何獲得一個(gè)字符的寬度和高度?                                               
                                                                                   
       可以利用FontMetrics 對(duì)象所提供的getHeight(), charWidth()或者是stringWidth()
     
       方法來(lái)獲得顯示某個(gè)字符或者是字符串所需要的高度和寬度。例如,在Graphics g中:


                                                                                   
       String Info = "Test String".FontMetrics metrics = getFontMetrics(g.getFont()); 
       int height = metrics.getHeight();         
       int width = metrics.stringWidth(Info);                                                                                
       關(guān)于這些方法的具體情況,請(qǐng)參考FontMetrics類的API文檔。   
     

    posted @ 2006-03-16 11:57 鄧華的碎碎念 閱讀(264) | 評(píng)論 (0)編輯 收藏

    碰到include亂碼的情況下.

    根據(jù)當(dāng)時(shí)頁(yè)面情況加入

    <%@ page pageEncoding="UTF-8"  %>

    這個(gè),在include頁(yè)面編譯的時(shí)候,可以明確指定該頁(yè)面用utf-8的編碼編譯
    posted @ 2006-03-16 11:57 鄧華的碎碎念 閱讀(365) | 評(píng)論 (0)編輯 收藏

    大家都知道,JAVA程序啟動(dòng)時(shí)都會(huì)JVM都會(huì)分配一個(gè)初始內(nèi)存和最大內(nèi)存給這個(gè)應(yīng)用程序。這個(gè)初始內(nèi)存和最大內(nèi)存在一定程度都會(huì)影響程序的性能。比如說(shuō)在應(yīng)用程序用到最大內(nèi)存的時(shí)候,JVM是要先去做垃圾回收的動(dòng)作,釋放被占用的一些內(nèi)存。
            所以想調(diào)整Tomcat的啟動(dòng)時(shí)初始內(nèi)存和最大內(nèi)存就需要向JVM聲明,一般的JAVA程序在運(yùn)行都可以通過(guò)中-Xms -Xmx來(lái)調(diào)整應(yīng)用程序的初始內(nèi)存和最大內(nèi)存: 
            如:java -Xms64m  -Xmx128m  a.jar.
    tomcat的啟動(dòng)程序是包裝過(guò)的,不能直接使用java -X..... tomcat.*來(lái)改變內(nèi)存的設(shè)置。在Tomcat在改變這個(gè)設(shè)置
    有兩種方法:
    1.    就需要在環(huán)境變量中加上TOMCAT_OPTS, CATALINA_OPTS兩個(gè)屬性,
            如 SET  CATALINA_OPTS= -Xms64m -Xmx512m;
            ms是最小的,mx是最大,64m, 512m分別是指內(nèi)存的容量.

    2.    修改Catalina.bat文件
           在166行“rem Execute Java with the applicable properties ”以下每行
    %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% 中的%CATALINA_OPTS% 替換成-Xms64m -Xmx512m

    其上為方法一
    --------------------------------------------------------------------------------------------------------------

    另外一個(gè)方法是
    在 tomcat_home/bin/catalina.sh 這個(gè)文件里
    找到下面:
    # ----- Execute The Requested Command -----------------------------------------
    echo "Using CATALINA_BASE:   $CATALINA_BASE"
    echo "Using CATALINA_HOME:   $CATALINA_HOME"
    echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
    echo "Using JAVA_HOME:       $JAVA_HOME"

    然后增加一行..
    # ----- Execute The Requested Command -----------------------------------------
    JAVA_OPTS="-server -Xmx512m -Xms128m -Djava.awt.headless=true "
    echo "Using CATALINA_BASE:   $CATALINA_BASE"
    echo "Using CATALINA_HOME:   $CATALINA_HOME"
    echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
    echo "Using JAVA_HOME:       $JAVA_HOME"

    就OK了.
    posted @ 2006-03-16 11:56 鄧華的碎碎念 閱讀(132) | 評(píng)論 (0)編輯 收藏

    java webapp i18n處理實(shí)踐   打印  E-mail 
    執(zhí)筆: 曹曉鋼    
     
    Sunday,2004年June月13日

    java webapp i18n處理實(shí)踐
    要點(diǎn):為了實(shí)現(xiàn)同屏多語(yǔ)言顯示/按照不同用戶locale顯示不同語(yǔ)言,必須全程采用UTF-8編碼。

    這幾天筆者剛好在處理roller的i18n,做一下總結(jié)。

    1, 對(duì)properties的處理,必須使用natice2ascii進(jìn)行編譯;然后采用boudle load.
    建議使用jstl進(jìn)行處理。
    例子:
    <%@ taglib uri="http://java.sun.com/jstl/fmt"                   prefix="fmt" %>

    <fmt:message key="bookmarkForm.correctBookmark" />

    2, 對(duì)jdbc連接的處理。對(duì)于特定的數(shù)據(jù)庫(kù)jdbc driver,需要調(diào)整參數(shù)。
    mysql的例子是:
     jdbc:mysql://localhost/roller?user=roller&password=roller&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&mysqlEncoding=utf8

    3, 對(duì)request/response處理,可以采用servlet filter進(jìn)行設(shè)置:
        public void doFilter(
            ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException
        {
            try
            {
                // insure that incoming data is parsed as UTF-8
                req.setCharacterEncoding("UTF-8");
            }
            catch (UnsupportedEncodingException e)
            {
                throw new ServletException("Can't set incoming encoding to UTF-8");
            }
           
            // keep JSTL and Struts Locale's in synch
            HttpSession session = ((HttpServletRequest)req).getSession();
            if (null != session)
            {
                Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
                if (locale == null)
                {
                    locale = req.getLocale();
                }
                if (req.getParameter("locale") != null)
                {
                    locale = new Locale(req.getParameter("locale"));
                }
                session.setAttribute(Globals.LOCALE_KEY, locale);
                Config.set(session, Config.FMT_LOCALE, locale);
            }
            chain.doFilter(req, res);
     ...
        }

    (這段代碼是從roller的代碼中摘錄的,seasky指出其編寫(xiě)不夠規(guī)范,需要refactor)

    4。對(duì)每個(gè)頁(yè)面,在response和頁(yè)面中都要指定為utf-8
    <%@ page language="java"
             errorPage="/error.jsp"
             contentType="text/html; charset=UTF-8" %>


    5, 對(duì)velocity的處理:
    in velocity.properties:
    # set encoding/charset to UTF-8
    input.encoding=UTF-8
    output.encoding=UTF-8
    default.contentType=text/html; charset=utf-8

    同時(shí),在java代碼中進(jìn)行template render時(shí),指定utf-8:
    VelocityEngine ve = ....;
    Template outty = getTemplate( "templateName", "UTF-8" );

    6, 對(duì)Gzip的處理:
    其實(shí)對(duì)Gzip處理沒(méi)有什么特殊,記住不要對(duì)ByteArrayStream轉(zhuǎn)換成char[]再進(jìn)行處理,而是在任何時(shí)候都使用byte[]。

    下載區(qū)中有一個(gè)例子

    7, 對(duì)regexp的處理。已經(jīng)有報(bào)告說(shuō)java.util.RegExp處理會(huì)導(dǎo)致輸出錯(cuò)誤。估計(jì)也是里面變換的時(shí)候用byte[]和char[]倒來(lái)倒去出了錯(cuò)。有條件的請(qǐng)try oro.
    (我還沒(méi)有測(cè)試)。

    8,對(duì)lucene 的修改。
    經(jīng)過(guò)測(cè)試,lucene 1.3-final不需要任何處理已經(jīng)可以正確處理中文,GB2312和utf-8都可以。





    Struts原理與實(shí)踐(5)
    作者:羅會(huì)波 發(fā)文時(shí)間:2004.09.24
    一個(gè)支持i18n的應(yīng)用程序應(yīng)該有如下一些特征:
    1增加支持的語(yǔ)言時(shí)要求不更改程序代碼
    2字符元素、消息、和圖象保存在原代碼之外
    3依賴于不同文化的數(shù)據(jù)如:日期時(shí)間、小數(shù)、及現(xiàn)金符號(hào)等數(shù)據(jù)對(duì)用戶的語(yǔ)言和地理位置應(yīng)該有正確的格式
    4應(yīng)用程序能迅速地適應(yīng)新語(yǔ)言和/或新地區(qū)

    Struts主要采用兩個(gè)i18n組件來(lái)實(shí)現(xiàn)國(guó)際化編程:

    第一個(gè)組件是一個(gè)被應(yīng)用程序控制器管理的消息類,它引用包含地區(qū)相關(guān)信息串的資源包。第二個(gè)組件是一個(gè)JSP定制標(biāo)簽,,它用于在View層呈現(xiàn)被控制器管理的實(shí)際的字符串。在我們前面的登錄例子中這兩方面的內(nèi)容都出現(xiàn)過(guò)。

    用Struts實(shí)現(xiàn)國(guó)際化編程的標(biāo)準(zhǔn)做法是:生成一個(gè)java屬性文件集。每個(gè)文件包含您的應(yīng)用程序要顯示的所有消息的鍵/值對(duì)。

    這些文件的命名要遵守如下規(guī)則,代表英文消息的文件可作為缺省的文件,它的名稱是ApplicationResources.properties;其他語(yǔ)種的文件在文件名中都要帶上相應(yīng)的地區(qū)和語(yǔ)言編碼串,如代表中文的文件名應(yīng)為ApplicationResources_zh_CN.properties。并且其他語(yǔ)種的文件與ApplicationResources.properties文件要放在同一目錄中。

    ApplicationResources.properties文件的鍵/值都是英文的,而其他語(yǔ)種文件的鍵是英文的,值則是對(duì)應(yīng)的語(yǔ)言。如在我們前面的登錄例子中的鍵/值對(duì):logon.jsp.prompt.username=Username:在中文文件中就是:logon.jsp.prompt.username=用戶名:當(dāng)然,在實(shí)際應(yīng)用時(shí)要把中文轉(zhuǎn)換為AscII碼。

    有了上一篇文章和以上介紹的一些基礎(chǔ)知識(shí)后。我們就可以將我們的登錄程序進(jìn)行國(guó)際化編程了。

    首先,我們所有jsp頁(yè)面文件的字符集都設(shè)置為UTF-8。即在頁(yè)面文件的開(kāi)始寫(xiě)如下指令行:

    ,在我們的登錄例子中已經(jīng)這樣做了,這里不需要再改動(dòng)。

    其次,將所有的request的字符集也設(shè)置為UTF-8。雖然,我們可以在每個(gè)文件中加入這樣的句子:request.setCharacterEncoding("UTF-8");來(lái)解決,但這樣顯得很麻煩。一種更簡(jiǎn)單的解決方法是使用filter。具體步驟如下:

    在mystruts\WEB-INF\classes目錄下再新建一個(gè)名為filters的目錄,新建一個(gè)名為:SetCharacterEncodingFilter的類,并保存在該目錄下。其實(shí),這個(gè)類并不要您親自來(lái)寫(xiě),可以借用tomcat中的例子。現(xiàn)將該例子的程序節(jié)選如下:

    package filters;
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.UnavailableException;
    
    /**
     * <p>Example filter that sets the character encoding to be used in parsing the
     * incoming request, either unconditionally or only if the client did not
     * specify a character encoding.  Configuration of this filter is based on
     * the following initialization parameters:</p>
     * <ul>
     * <li><strong>encoding</strong> - The character encoding to be configured
     *     for this request, either conditionally or unconditionally based on
     *     the <code>ignore</code> initialization parameter.  This parameter
     *     is required, so there is no default.</li>
     * <li><strong>ignore</strong> - If set to "true", any character encoding
     *     specified by the client is ignored, and the value returned by the
     *     <code>selectEncoding()</code> method is set.  If set to "false,
     *     <code>selectEncoding()</code> is called <strong>only</strong> if the
     *     client has not already specified an encoding.  By default, this
     *     parameter is set to "true".</li>
     * </ul>
     *
     * <p>Although this filter can be used unchanged, it is also easy to
     * subclass it and make the <code>selectEncoding()</code> method more
     * intelligent about what encoding to choose, based on characteristics of
     * the incoming request (such as the values of the <code>Accept-Language</code>
     * and <code>User-Agent</code> headers, or a value stashed in the current
     * user's session.</p>
     *
     * @author Craig McClanahan
     * @version $Revision: 1.2 $ $Date: 2001/10/17 22:53:19 $
     */
    
    public class SetCharacterEncodingFilter implements Filter {
    
    
        // ----------------------------------------------------- Instance Variables
    
    
        /**
         * The default character encoding to set for requests that pass through
         * this filter.
         */
        protected String encoding = null;
    
    
        /**
         * The filter configuration object we are associated with.  If this value
         * is null, this filter instance is not currently configured.
         */
        protected FilterConfig filterConfig = null;
    
    
        /**
         * Should a character encoding specified by the client be ignored?
         */
        protected boolean ignore = true;
    
    
        // --------------------------------------------------------- Public Methods
    
    
        /**
         * Take this filter out of service.
         */
        public void destroy() {
    
            this.encoding = null;
            this.filterConfig = null;
    
        }
    
    
        /**
         * Select and set (if specified) the character encoding to be used to
         * interpret request parameters for this request.
         *
         * @param request The servlet request we are processing
         * @param result The servlet response we are creating
         * @param chain The filter chain we are processing
         *
         * @exception IOException if an input/output error occurs
         * @exception ServletException if a servlet error occurs
         */
        public void doFilter(ServletRequest request, ServletResponse response,
                             FilterChain chain)
            throws IOException, ServletException {
    
            // Conditionally select and set the character encoding to be used
            if (ignore || (request.getCharacterEncoding() == null)) {
                String encoding = selectEncoding(request);
                if (encoding != null)
                    request.setCharacterEncoding(encoding);
            }
    
            // Pass control on to the next filter
            chain.doFilter(request, response);
    
        }
    
    
        /**
         * Place this filter into service.
         *
         * @param filterConfig The filter configuration object
         */
        public void init(FilterConfig filterConfig) throws ServletException {
    
            this.filterConfig = filterConfig;
            this.encoding = filterConfig.getInitParameter("encoding");
            String value = filterConfig.getInitParameter("ignore");
            if (value == null)
                this.ignore = true;
            else if (value.equalsIgnoreCase("true"))
                this.ignore = true;
            else if (value.equalsIgnoreCase("yes"))
                this.ignore = true;
            else
                this.ignore = false;
    
        }
    
    
        // ------------------------------------------------------ Protected Methods
    
    
        /**
         * Select an appropriate character encoding to be used, based on the
         * characteristics of the current request and/or filter initialization
         * parameters.  If no character encoding should be set, return
         * <code>null</code>.
         * <p>
         * The default implementation unconditionally returns the value configured
         * by the <strong>encoding</strong> initialization parameter for this
         * filter.
         *
         * @param request The servlet request we are processing
         */
        protected String selectEncoding(ServletRequest request) {
    
            return (this.encoding);
    
        }
    
    }


    其中,request.setCharacterEncoding(encoding);是一個(gè)關(guān)鍵句子。

    為了讓該類工作,我們還要在web.xml文件中對(duì)它進(jìn)行配置,配置代碼如下:

    <filter>
        <filter-name>Set Character Encoding</filter-name>
        <filter-class>filters.SetCharacterEncodingFilter</filter-class>
        <init-param>
          <param-name>encoding</param-name>
          <param-value>UTF-8</param-value>
        </init-param>
      </filter>
      <filter-mapping>
        <filter-name>Set Character Encoding</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>


    最后,就是準(zhǔn)備資源包文件,我們以創(chuàng)建一個(gè)中文文件為例:

    將ApplicationResources.properties文件打開(kāi),另存為ApplicationResources_zh.properties,這只是一個(gè)過(guò)渡性質(zhì)的文件。將文件中鍵/值對(duì)的值都用中文表示。更改完后的代碼如下:

    #Application Resource for the logon.jsp
    logon.jsp.title=登錄頁(yè)
    logon.jsp.page.heading=歡迎 世界!
    logon.jsp.prompt.username=用戶名:
    logon.jsp.prompt.password=口令:
    logon.jsp.prompt.submit=提交
    logon.jsp.prompt.reset=復(fù)位
    
    #Application Resource for the main.jsp
    main.jsp.title=主頁(yè)
    main.jsp.welcome=歡迎:
    
    #Application Resource for the LogonAction.java
    error.missing.username=<li><font color="red">沒(méi)有輸入用戶名</font></li>
    error.missing.password=<li><font color="red">沒(méi)有輸入口令</font></li>
    
    #Application Resource for the UserInfoBo.java
    error.noMatch=<li><font color="red">沒(méi)有匹配的用戶</font></li>
    
    #Application Resource for the UserInfoBo.java
    error.logon.invalid=<li><font color="red">用戶名/口令是無(wú)效的</font></li>
    error.removed.user=<li><font color="red">找不到該用戶</font></li>
    error.unexpected=<li><font color="red">不可預(yù)期的錯(cuò)誤</font></li>


    使用native2ascii工具將上面文件中的中文字符轉(zhuǎn)換為ascii碼,并生成一個(gè)最終使用的資源文件ApplicationResources_zh_CN.properties。

    具體做法是打開(kāi)一個(gè)dos窗口,到mystruts\WEB-INF\classes目錄下,運(yùn)行如下語(yǔ)句:

    native2ascii -encoding GBK ApplicationResources_zh.properties ApplicationResources_zh_CN.properties

    生成的文件ApplicationResources_zh_CN.properties的內(nèi)容如下:

    #Application Resource for the logon.jsp
    logon.jsp.title=\u767b\u5f55\u9875
    logon.jsp.page.heading=\u6b22\u8fce \u4e16\u754c!
    logon.jsp.prompt.username=\u7528\u6237\u540d:
    logon.jsp.prompt.password=\u53e3\u4ee4:
    logon.jsp.prompt.submit=\u63d0\u4ea4
    logon.jsp.prompt.reset=\u590d\u4f4d
    
    #Application Resource for the main.jsp
    main.jsp.title=\u4e3b\u9875
    main.jsp.welcome=\u6b22\u8fce:
    
    #Application Resource for the LogonAction.java
    error.missing.username=<li><font color="red">\u6ca1\u6709\u8f93\u5165\u7528\u6237\u540d</font></li>
    error.missing.password=<li><font color="red">\u6ca1\u6709\u8f93\u5165\u53e3\u4ee4</font></li>
    
    #Application Resource for the UserInfoBo.java
    error.noMatch=<li><font color="red">\u6ca1\u6709\u5339\u914d\u7684\u7528\u6237</font></li>
    
    #Application Resource for the UserInfoBo.java
    error.logon.invalid=<li><font color="red">\u7528\u6237\u540d/\u53e3\u4ee4\u662f\u65e0\u6548\u7684</font></li>
    error.removed.user=<li><font color="red">\u627e\u4e0d\u5230\u8be5\u7528\u6237</font></li>
    error.unexpected=<li><font color="red">\u4e0d\u53ef\u9884\u671f\u7684\u9519\u8bef</font></li>


    從這里可以看出,所有的中文字都轉(zhuǎn)換成了對(duì)應(yīng)的Unicode碼。

    現(xiàn)在,再運(yùn)行登錄例子程序,您會(huì)發(fā)現(xiàn)它已經(jīng)是顯示的中文了。在瀏覽器的"工具"--"Internet選項(xiàng)"的"語(yǔ)言首選項(xiàng)"對(duì)話框中,去掉"中文(中國(guó))"加上英文,再試登錄程序,此時(shí),又會(huì)顯示英文。這就是說(shuō)不同國(guó)家(地區(qū))的客戶都可以看到自己語(yǔ)言的內(nèi)容,這就實(shí)現(xiàn)了國(guó)際化編程的基本要求。如果還要顯示其他語(yǔ)言,可采用類似處理中文的方法進(jìn)行,這里就不細(xì)講了。

    本文中的例子程序所采用的數(shù)據(jù)庫(kù)仍然是MS SQLServer2000,數(shù)據(jù)庫(kù)字符集為gbk。實(shí)驗(yàn)表明,對(duì)簡(jiǎn)、繁體中文,英文及日文字符都能支持。

    參考文獻(xiàn):
    《Programming Jakarta Struts》Chuck Cavaness著
    《Mastering Jakarta Struts》James Goodwill著

    本文作者:羅會(huì)波 湖北省當(dāng)陽(yáng)市國(guó)稅局信息中心 可通過(guò)lhbf@sina.com與他聯(lián)系
    posted @ 2006-03-16 11:56 鄧華的碎碎念 閱讀(443) | 評(píng)論 (0)編輯 收藏

    /**
     * @(#)CnToSpell.java
     * 版權(quán)聲明 Easydozer 版權(quán)所有 違者必究
     *
     * 修訂記錄:
     * 1)更改者:Easydozer
     *   時(shí) 間:2004-10-20 
     *   描 述:創(chuàng)建
     */
    package com.easydozer.commons.util;

    import java.util.Iterator;
    import java.util.LinkedHashMap;
    import java.util.Set;

    /**
     * <pre>漢字轉(zhuǎn)化為全拼</pre>
     * <BR><DL><DT><B>JDK版本:</B></DT><BR><DD>1.4</DD></DL>
     * @author   謝計(jì)生
     * @version  1.0
     * @see     
     * @since   1.0
     */
    public class CnToSpell
    {
      private static LinkedHashMap spellMap = null;

      static
      {
        if(spellMap == null){
          spellMap = new LinkedHashMap(400);
        }
        initialize();
        System.out.println("Chinese transfer Spell Done.");
      }

      private CnToSpell()
      {
      }

      private static void spellPut(String spell,int ascii)
      {
        spellMap.put(spell,new Integer(ascii));
      }

      private static void initialize()
      {
        spellPut("a", -20319);
        spellPut("ai", -20317);
        spellPut("an", -20304);
        spellPut("ang", -20295);
        spellPut("ao", -20292);
        spellPut("ba", -20283);
        spellPut("bai", -20265);
        spellPut("ban", -20257);
        spellPut("bang", -20242);
        spellPut("bao", -20230);
        spellPut("bei", -20051);
        spellPut("ben", -20036);
        spellPut("beng", -20032);
        spellPut("bi", -20026);
        spellPut("bian", -20002);
        spellPut("biao", -19990);
        spellPut("bie", -19986);
        spellPut("bin", -19982);
        spellPut("bing", -19976);
        spellPut("bo", -19805);
        spellPut("bu", -19784);
        spellPut("ca", -19775);
        spellPut("cai", -19774);
        spellPut("can", -19763);
        spellPut("cang", -19756);
        spellPut("cao", -19751);
        spellPut("ce", -19746);
        spellPut("ceng", -19741);
        spellPut("cha", -19739);
        spellPut("chai", -19728);
        spellPut("chan", -19725);
        spellPut("chang", -19715);
        spellPut("chao", -19540);
        spellPut("che", -19531);
        spellPut("chen", -19525);
        spellPut("cheng", -19515);
        spellPut("chi", -19500);
        spellPut("chong", -19484);
        spellPut("chou", -19479);
        spellPut("chu", -19467);
        spellPut("chuai", -19289);
        spellPut("chuan", -19288);
        spellPut("chuang", -19281);
        spellPut("chui", -19275);
        spellPut("chun", -19270);
        spellPut("chuo", -19263);
        spellPut("ci", -19261);
        spellPut("cong", -19249);
        spellPut("cou", -19243);
        spellPut("cu", -19242);
        spellPut("cuan", -19238);
        spellPut("cui", -19235);
        spellPut("cun", -19227);
        spellPut("cuo", -19224);
        spellPut("da", -19218);
        spellPut("dai", -19212);
        spellPut("dan", -19038);
        spellPut("dang", -19023);
        spellPut("dao", -19018);
        spellPut("de", -19006);
        spellPut("deng", -19003);
        spellPut("di", -18996);
        spellPut("dian", -18977);
        spellPut("diao", -18961);
        spellPut("die", -18952);
        spellPut("ding", -18783);
        spellPut("diu", -18774);
        spellPut("dong", -18773);
        spellPut("dou", -18763);
        spellPut("du", -18756);
        spellPut("duan", -18741);
        spellPut("dui", -18735);
        spellPut("dun", -18731);
        spellPut("duo", -18722);
        spellPut("e", -18710);
        spellPut("en", -18697);
        spellPut("er", -18696);
        spellPut("fa", -18526);
        spellPut("fan", -18518);
        spellPut("fang", -18501);
        spellPut("fei", -18490);
        spellPut("fen", -18478);
        spellPut("feng", -18463);
        spellPut("fo", -18448);
        spellPut("fou", -18447);
        spellPut("fu", -18446);
        spellPut("ga", -18239);
        spellPut("gai", -18237);
        spellPut("gan", -18231);
        spellPut("gang", -18220);
        spellPut("gao", -18211);
        spellPut("ge", -18201);
        spellPut("gei", -18184);
        spellPut("gen", -18183);
        spellPut("geng", -18181);
        spellPut("gong", -18012);
        spellPut("gou", -17997);
        spellPut("gu", -17988);
        spellPut("gua", -17970);
        spellPut("guai", -17964);
        spellPut("guan", -17961);
        spellPut("guang", -17950);
        spellPut("gui", -17947);
        spellPut("gun", -17931);
        spellPut("guo", -17928);
        spellPut("ha", -17922);
        spellPut("hai", -17759);
        spellPut("han", -17752);
        spellPut("hang", -17733);
        spellPut("hao", -17730);
        spellPut("he", -17721);
        spellPut("hei", -17703);
        spellPut("hen", -17701);
        spellPut("heng", -17697);
        spellPut("hong", -17692);
        spellPut("hou", -17683);
        spellPut("hu", -17676);
        spellPut("hua", -17496);
        spellPut("huai", -17487);
        spellPut("huan", -17482);
        spellPut("huang", -17468);
        spellPut("hui", -17454);
        spellPut("hun", -17433);
        spellPut("huo", -17427);
        spellPut("ji", -17417);
        spellPut("jia", -17202);
        spellPut("jian", -17185);
        spellPut("jiang", -16983);
        spellPut("jiao", -16970);
        spellPut("jie", -16942);
        spellPut("jin", -16915);
        spellPut("jing", -16733);
        spellPut("jiong", -16708);
        spellPut("jiu", -16706);
        spellPut("ju", -16689);
        spellPut("juan", -16664);
        spellPut("jue", -16657);
        spellPut("jun", -16647);
        spellPut("ka", -16474);
        spellPut("kai", -16470);
        spellPut("kan", -16465);
        spellPut("kang", -16459);
        spellPut("kao", -16452);
        spellPut("ke", -16448);
        spellPut("ken", -16433);
        spellPut("keng", -16429);
        spellPut("kong", -16427);
        spellPut("kou", -16423);
        spellPut("ku", -16419);
        spellPut("kua", -16412);
        spellPut("kuai", -16407);
        spellPut("kuan", -16403);
        spellPut("kuang", -16401);
        spellPut("kui", -16393);
        spellPut("kun", -16220);
        spellPut("kuo", -16216);
        spellPut("la", -16212);
        spellPut("lai", -16205);
        spellPut("lan", -16202);
        spellPut("lang", -16187);
        spellPut("lao", -16180);
        spellPut("le", -16171);
        spellPut("lei", -16169);
        spellPut("leng", -16158);
        spellPut("li", -16155);
        spellPut("lia", -15959);
        spellPut("lian", -15958);
        spellPut("liang", -15944);
        spellPut("liao", -15933);
        spellPut("lie", -15920);
        spellPut("lin", -15915);
        spellPut("ling", -15903);
        spellPut("liu", -15889);
        spellPut("long", -15878);
        spellPut("lou", -15707);
        spellPut("lu", -15701);
        spellPut("lv", -15681);
        spellPut("luan", -15667);
        spellPut("lue", -15661);
        spellPut("lun", -15659);
        spellPut("luo", -15652);
        spellPut("ma", -15640);
        spellPut("mai", -15631);
        spellPut("man", -15625);
        spellPut("mang", -15454);
        spellPut("mao", -15448);
        spellPut("me", -15436);
        spellPut("mei", -15435);
        spellPut("men", -15419);
        spellPut("meng", -15416);
        spellPut("mi", -15408);
        spellPut("mian", -15394);
        spellPut("miao", -15385);
        spellPut("mie", -15377);
        spellPut("min", -15375);
        spellPut("ming", -15369);
        spellPut("miu", -15363);
        spellPut("mo", -15362);
        spellPut("mou", -15183);
        spellPut("mu", -15180);
        spellPut("na", -15165);
        spellPut("nai", -15158);
        spellPut("nan", -15153);
        spellPut("nang", -15150);
        spellPut("nao", -15149);
        spellPut("ne", -15144);
        spellPut("nei", -15143);
        spellPut("nen", -15141);
        spellPut("neng", -15140);
        spellPut("ni", -15139);
        spellPut("nian", -15128);
        spellPut("niang", -15121);
        spellPut("niao", -15119);
        spellPut("nie", -15117);
        spellPut("nin", -15110);
        spellPut("ning", -15109);
        spellPut("niu", -14941);
        spellPut("nong", -14937);
        spellPut("nu", -14933);
        spellPut("nv", -14930);
        spellPut("nuan", -14929);
        spellPut("nue", -14928);
        spellPut("nuo", -14926);
        spellPut("o", -14922);
        spellPut("ou", -14921);
        spellPut("pa", -14914);
        spellPut("pai", -14908);
        spellPut("pan", -14902);
        spellPut("pang", -14894);
        spellPut("pao", -14889);
        spellPut("pei", -14882);
        spellPut("pen", -14873);
        spellPut("peng", -14871);
        spellPut("pi", -14857);
        spellPut("pian", -14678);
        spellPut("piao", -14674);
        spellPut("pie", -14670);
        spellPut("pin", -14668);
        spellPut("ping", -14663);
        spellPut("po", -14654);
        spellPut("pu", -14645);
        spellPut("qi", -14630);
        spellPut("qia", -14594);
        spellPut("qian", -14429);
        spellPut("qiang", -14407);
        spellPut("qiao", -14399);
        spellPut("qie", -14384);
        spellPut("qin", -14379);
        spellPut("qing", -14368);
        spellPut("qiong", -14355);
        spellPut("qiu", -14353);
        spellPut("qu", -14345);
        spellPut("quan", -14170);
        spellPut("que", -14159);
        spellPut("qun", -14151);
        spellPut("ran", -14149);
        spellPut("rang", -14145);
        spellPut("rao", -14140);
        spellPut("re", -14137);
        spellPut("ren", -14135);
        spellPut("reng", -14125);
        spellPut("ri", -14123);
        spellPut("rong", -14122);
        spellPut("rou", -14112);
        spellPut("ru", -14109);
        spellPut("ruan", -14099);
        spellPut("rui", -14097);
        spellPut("run", -14094);
        spellPut("ruo", -14092);
        spellPut("sa", -14090);
        spellPut("sai", -14087);
        spellPut("san", -14083);
        spellPut("sang", -13917);
        spellPut("sao", -13914);
        spellPut("se", -13910);
        spellPut("sen", -13907);
        spellPut("seng", -13906);
        spellPut("sha", -13905);
        spellPut("shai", -13896);
        spellPut("shan", -13894);
        spellPut("shang", -13878);
        spellPut("shao", -13870);
        spellPut("she", -13859);
        spellPut("shen", -13847);
        spellPut("sheng", -13831);
        spellPut("shi", -13658);
        spellPut("shou", -13611);
        spellPut("shu", -13601);
        spellPut("shua", -13406);
        spellPut("shuai", -13404);
        spellPut("shuan", -13400);
        spellPut("shuang", -13398);
        spellPut("shui", -13395);
        spellPut("shun", -13391);
        spellPut("shuo", -13387);
        spellPut("si", -13383);
        spellPut("song", -13367);
        spellPut("sou", -13359);
        spellPut("su", -13356);
        spellPut("suan", -13343);
        spellPut("sui", -13340);
        spellPut("sun", -13329);
        spellPut("suo", -13326);
        spellPut("ta", -13318);
        spellPut("tai", -13147);
        spellPut("tan", -13138);
        spellPut("tang", -13120);
        spellPut("tao", -13107);
        spellPut("te", -13096);
        spellPut("teng", -13095);
        spellPut("ti", -13091);
        spellPut("tian", -13076);
        spellPut("tiao", -13068);
        spellPut("tie", -13063);
        spellPut("ting", -13060);
        spellPut("tong", -12888);
        spellPut("tou", -12875);
        spellPut("tu", -12871);
        spellPut("tuan", -12860);
        spellPut("tui", -12858);
        spellPut("tun", -12852);
        spellPut("tuo", -12849);
        spellPut("wa", -12838);
        spellPut("wai", -12831);
        spellPut("wan", -12829);
        spellPut("wang", -12812);
        spellPut("wei", -12802);
        spellPut("wen", -12607);
        spellPut("weng", -12597);
        spellPut("wo", -12594);
        spellPut("wu", -12585);
        spellPut("xi", -12556);
        spellPut("xia", -12359);
        spellPut("xian", -12346);
        spellPut("xiang", -12320);
        spellPut("xiao", -12300);
        spellPut("xie", -12120);
        spellPut("xin", -12099);
        spellPut("xing", -12089);
        spellPut("xiong", -12074);
        spellPut("xiu", -12067);
        spellPut("xu", -12058);
        spellPut("xuan", -12039);
        spellPut("xue", -11867);
        spellPut("xun", -11861);
        spellPut("ya", -11847);
        spellPut("yan", -11831);
        spellPut("yang", -11798);
        spellPut("yao", -11781);
        spellPut("ye", -11604);
        spellPut("yi", -11589);
        spellPut("yin", -11536);
        spellPut("ying", -11358);
        spellPut("yo", -11340);
        spellPut("yong", -11339);
        spellPut("you", -11324);
        spellPut("yu", -11303);
        spellPut("yuan", -11097);
        spellPut("yue", -11077);
        spellPut("yun", -11067);
        spellPut("za", -11055);
        spellPut("zai", -11052);
        spellPut("zan", -11045);
        spellPut("zang", -11041);
        spellPut("zao", -11038);
        spellPut("ze", -11024);
        spellPut("zei", -11020);
        spellPut("zen", -11019);
        spellPut("zeng", -11018);
        spellPut("zha", -11014);
        spellPut("zhai", -10838);
        spellPut("zhan", -10832);
        spellPut("zhang", -10815);
        spellPut("zhao", -10800);
        spellPut("zhe", -10790);
        spellPut("zhen", -10780);
        spellPut("zheng", -10764);
        spellPut("zhi", -10587);
        spellPut("zhong", -10544);
        spellPut("zhou", -10533);
        spellPut("zhu", -10519);
        spellPut("zhua", -10331);
        spellPut("zhuai", -10329);
        spellPut("zhuan", -10328);
        spellPut("zhuang", -10322);
        spellPut("zhui", -10315);
        spellPut("zhun", -10309);
        spellPut("zhuo", -10307);
        spellPut("zi", -10296);
        spellPut("zong", -10281);
        spellPut("zou", -10274);
        spellPut("zu", -10270);
        spellPut("zuan", -10262);
        spellPut("zui", -10260);
        spellPut("zun", -10256);
        spellPut("zuo", -10254);
      }

      /**
       * 獲得單個(gè)漢字的Ascii.
       * @param cn char
       * 漢字字符
       * @return int
       * 錯(cuò)誤返回 0,否則返回ascii
       */
      public static int getCnAscii(char cn)
      {
        byte[] bytes = (String.valueOf(cn)).getBytes();
        if(bytes == null || bytes.length > 2 || bytes.length <= 0){ //錯(cuò)誤
          return 0;
        }
        if(bytes.length == 1){ //英文字符
          return bytes[0];
        }
        if(bytes.length == 2){ //中文字符
          int hightByte = 256 + bytes[0];
          int lowByte = 256 + bytes[1];

          int ascii = (256 * hightByte + lowByte) - 256 * 256;

          //System.out.println("ASCII=" + ascii);

          return ascii;
        }

        return 0; //錯(cuò)誤
      }

      /**
       * 根據(jù)ASCII碼到SpellMap中查找對(duì)應(yīng)的拼音
       * @param ascii int
       * 字符對(duì)應(yīng)的ASCII
       * @return String
       * 拼音,首先判斷ASCII是否>0&<160,如果是返回對(duì)應(yīng)的字符,
       * <BR>否則到SpellMap中查找,如果沒(méi)有找到拼音,則返回null,如果找到則返回拼音.
       */
      public static String getSpellByAscii(int ascii)
      {
        if(ascii > 0 && ascii < 160){ //單字符
          return String.valueOf((char)ascii);
        }

        if(ascii < -20319 || ascii > -10247){ //不知道的字符
          return null;
        }

        Set keySet = spellMap.keySet();
        Iterator it = keySet.iterator();

        String spell0 = null;;
        String spell = null;

        int asciiRang0 = -20319;
        int asciiRang;
        while(it.hasNext()){

          spell = (String)it.next();
          Object valObj = spellMap.get(spell);
          if(valObj instanceof Integer){
            asciiRang = ((Integer)valObj).intValue();

            if(ascii >= asciiRang0 && ascii < asciiRang){ //區(qū)間找到
              return(spell0 == null) ? spell : spell0;
            }
            else{
              spell0 = spell;
              asciiRang0 = asciiRang;
            }
          }
        }

        return null;

      }

      /**
       * 返回字符串的全拼,是漢字轉(zhuǎn)化為全拼,其它字符不進(jìn)行轉(zhuǎn)換
       * @param cnStr String
       * 字符串
       * @return String
       * 轉(zhuǎn)換成全拼后的字符串
       */
      public static String getFullSpell(String cnStr)
      {
        if(null == cnStr || "".equals(cnStr.trim())){
          return cnStr;
        }

        char[] chars = cnStr.toCharArray();
        StringBuffer retuBuf = new StringBuffer();
        for(int i = 0,Len = chars.length;i < Len;i++){
          int ascii = getCnAscii(chars[i]);
          if(ascii == 0){ //取ascii時(shí)出錯(cuò)
            retuBuf.append(chars[i]);
          }
          else{
            String spell = getSpellByAscii(ascii);
            if(spell == null){
              retuBuf.append(chars[i]);
            }
            else{
              retuBuf.append(spell);
            } // end of if spell == null
          } // end of if ascii <= -20400
        } // end of for

        return retuBuf.toString();
      }

      public static String getFirstSpell(String cnStr)
      {
        return null;
      }

      public static void main(String[] args)
      {
        String str = null;
        str = "謝海101普降喜雨";
        System.out.println("Spell=" + CnToSpell.getFullSpell(str));
       
        str = "張牙舞爪》。,";
        System.out.println("Spell=" + CnToSpell.getFullSpell(str));
       
        str = "李鵬,可恥下場(chǎng)。";
        System.out.println("Spell=" + CnToSpell.getFullSpell(str));
       
        str = "豬油,豬八戒。";
        System.out.println("Spell=" + CnToSpell.getFullSpell(str));
      }
    }

    posted @ 2006-03-16 11:55 鄧華的碎碎念 閱讀(594) | 評(píng)論 (0)編輯 收藏

    當(dāng)在linux服務(wù)器上沒(méi)有裝xwindows時(shí), 處理圖像時(shí)會(huì)報(bào)
    java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
    這個(gè)錯(cuò).

    解決方法:

    在tomcat的catalina.sh文件中

    找到

    # ----- Execute The Requested Command -----------------------------------------
    echo "Using CATALINA_BASE:   $CATALINA_BASE"
    echo "Using CATALINA_HOME:   $CATALINA_HOME"
    echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
    echo "Using JAVA_HOME:       $JAVA_HOME"

    加入

    JAVA_OPTS="-Djava.awt.headless=true "

    就能解決問(wèn)題.
    posted @ 2006-03-16 11:54 鄧華的碎碎念 閱讀(136) | 評(píng)論 (0)編輯 收藏

    hibernate8ide在新版本中已經(jīng)改名叫console了.  用如下方法運(yùn)行,可以利用項(xiàng)目中已經(jīng)建好的配置文件, 不用再配置, 減少了hibernamte8ide出錯(cuò)的機(jī)會(huì). 以前直接RUN的時(shí)候, 有各種錯(cuò)誤出現(xiàn). 搞得人很頭暈的.

    下載最新版hibernate-extensions, 解壓到相關(guān)目錄.

    在jb的工程中引入console目錄下的hibernateconsole.jar, 再引入console\lib目錄下的所有jar文件

    創(chuàng)建一個(gè)StartHibern8IDE.java文件, 拷貝下面的代碼,然后run.

    參考了一篇hibernate8ide運(yùn)行在eclipse中的文章.

    當(dāng)然,下面的代碼,再eclipse中是一樣的用的.

    用下面的代碼運(yùn)行,可以解決中文問(wèn)題.

    import java.awt.Font;

    import javax.swing.UIManager;

    import com.jgoodies.clearlook.ClearLookManager;
    import com.jgoodies.clearlook.ClearLookMode;
    import com.jgoodies.plaf.plastic.PlasticXPLookAndFeel;


    import net.sf.hibernate.cfg.Configuration;
    import net.sf.hibernate.console.*;


    public class StartHibern8IDE {

    public static void main(String[] args) throws Exception {
    Configuration configuration = new Configuration();

    try {
        if (System.getProperty("sun.awt.exception.handler")==null) {
           System.setProperty("sun.awt.exception.handler", AWTExceptionHandler.class.getName());
        } else {
           System.err.println("could not install AWT handler ;(");
        }
        ClearLookManager.setMode(ClearLookMode.ON);
        UIManager.setLookAndFeel(new PlasticXPLookAndFeel());

     setUIFont (new javax.swing.plaf.FontUIResource("宋體",Font.PLAIN,12));
              
     configuration.configure();

    // run

     Start.startWith(configuration);

     } catch (Exception e) { // noop
         e.printStackTrace();
     }

    }

    public static void setUIFont (javax.swing.plaf.FontUIResource f){
        java.util.Enumeration keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
          Object key = keys.nextElement();
          Object value = UIManager.get (key);
          if (value instanceof javax.swing.plaf.FontUIResource)
            UIManager.put (key, f);
          }
        }
    }

     

    posted @ 2006-03-16 11:54 鄧華的碎碎念 閱讀(157) | 評(píng)論 (0)編輯 收藏

    在1G內(nèi)存下.用這個(gè)參數(shù)很管用. 速度感覺(jué)加快

    eclipse.exe -vmargs -Xverify:none -XX:+UseParallelGC -XX:PermSize=20M -Xms64M -Xmx512M

    posted @ 2006-03-16 11:54 鄧華的碎碎念 閱讀(549) | 評(píng)論 (0)編輯 收藏

    我們知道,在jbuilder中,編輯xml文件的話, 如果在頭部加了dtd, JB會(huì)自動(dòng)去網(wǎng)上下載這個(gè)DTD,來(lái)驗(yàn)證XML文件, 這功能當(dāng)然是非

    常好的, 但是,給我們?cè)斐闪怂俣嚷睦_, 特別是打開(kāi)xml和保存,修改的時(shí)候.

    其實(shí)在jb中,是可以改變這個(gè)速度的. 采用的是地址映射的方法, 把HTTP地址,映射到本地的目錄上來(lái).

    我是在hibernate的xml文件中實(shí)踐的

    先用flashget 下載 http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd 這個(gè)DTD文件. 把他放到硬盤(pán)上的一

    個(gè)目錄里,然后在JB里,選擇TOOLS, preferences,  然后選xml 下面的 System ID Catalog, 點(diǎn)ADD,加入一個(gè)映射

    在輸入框是里填入http://hibernate.sourceforge.net/ 這代表要把這段網(wǎng)址映射成硬盤(pán)上的某個(gè)目錄, 然后下面選directy, 選擇放上面dtd的目錄.

    當(dāng)然也可以映射文件. 方法同上,只是remap成file就OK了.

    以上方法,是在jbuilderX中通過(guò)的

    posted @ 2006-03-16 11:53 鄧華的碎碎念 閱讀(103) | 評(píng)論 (0)編輯 收藏

    僅列出標(biāo)題
    共5頁(yè): 上一頁(yè) 1 2 3 4 5 下一頁(yè) 
    主站蜘蛛池模板: 久99精品视频在线观看婷亚洲片国产一区一级在线 | 亚洲精品夜夜夜妓女网| 91热久久免费精品99| 女人18毛片a级毛片免费| 亚洲精品影院久久久久久| 免费人成动漫在线播放r18 | www免费插插视频| 91福利免费视频| 久久久久久亚洲Av无码精品专口 | 亚洲综合在线观看视频| 99ee6热久久免费精品6| 亚洲第一精品电影网| 69式国产真人免费视频| 亚洲精品无码不卡在线播HE| 国内精品一级毛片免费看| 亚洲午夜国产片在线观看| 成人片黄网站色大片免费观看APP| 国产成人亚洲综合无码精品| 看一级毛片免费观看视频| 国产一卡二卡3卡四卡免费| 亚洲精品理论电影在线观看| 毛片无码免费无码播放| 亚洲中文字幕无码一去台湾| 19禁啪啪无遮挡免费网站| 久久久久久亚洲精品影院| 亚洲av无码不卡私人影院| 国产永久免费高清在线| 亚洲婷婷综合色高清在线| 国产一区二区三区无码免费| 国产精品99爱免费视频| 蜜芽亚洲av无码精品色午夜| 插B内射18免费视频| 亚洲五月午夜免费在线视频| 老司机亚洲精品影院| 在线观看亚洲免费| 在线亚洲午夜片AV大片| 在线观看免费视频一区| 亚洲专区中文字幕| 亚洲熟伦熟女新五十路熟妇| 亚洲成人在线免费观看| 黄页网址大全免费观看12网站|