??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品视频99,校园春色欧美,精品视频在线观看网站http://www.aygfsteel.com/keweibo/category/25924.html<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- iteye 460 60 --> <ins class="adsbygoogle" style="display:inline-block;width:468px;height:60px" data-ad-client="ca-pub-2876867208357149" data-ad-slot="0418982663"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> zh-cnFri, 16 Nov 2018 19:22:29 GMTFri, 16 Nov 2018 19:22:29 GMT60Java8 Stream 分组l计信息http://www.aygfsteel.com/keweibo/articles/433494.htmlKeKeThu, 15 Nov 2018 02:02:00 GMThttp://www.aygfsteel.com/keweibo/articles/433494.htmlhttp://www.aygfsteel.com/keweibo/comments/433494.htmlhttp://www.aygfsteel.com/keweibo/articles/433494.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/433494.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/433494.html利用Java的Stream分组l计信息


Ke 2018-11-15 10:02 发表评论
]]>
解决Access restriction: The type XXXX is not accessible due to restriction on required libraryhttp://www.aygfsteel.com/keweibo/articles/376754.htmlKeKeFri, 27 Apr 2012 03:55:00 GMThttp://www.aygfsteel.com/keweibo/articles/376754.htmlhttp://www.aygfsteel.com/keweibo/comments/376754.htmlhttp://www.aygfsteel.com/keweibo/articles/376754.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/376754.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/376754.html

import java.io.FileInputStream;

import sun.audio.AudioPlayer;
import sun.audio.AudioStream;

public class Sound {
 public   static   void   main(String   args[])  
    {  
  try   {  
          FileInputStream   fileau=new   FileInputStream("hint.wav");  
          AudioStream   as=new   AudioStream(fileau);  
          AudioPlayer.player.start(as);  
            }  
        catch   (Exception   e)   {}  
      }  
}


解决办法Q在Build Path里面把JRE System LibraryU除后重新添加进去,问题解决



Ke 2012-04-27 11:55 发表评论
]]>
linux JDK 三种配置环境变量的方?/title><link>http://www.aygfsteel.com/keweibo/articles/366113.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Mon, 12 Dec 2011 00:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/366113.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/366113.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/366113.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/366113.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/366113.html</trackback:ping><description><![CDATA[@import url(http://www.aygfsteel.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); <span> <p>三种配置环境变量的方?br /> <br /> 1. 修改/etc/profile文g <br /> 如果你的计算Z仅作为开发用时推荐使用q种ҎQ因为所?strong>用户</strong>的shell都有权用这些环境变量,可能会给pȝ带来安全性问题?<br /> ·用文本编辑器打开/etc/profile <br /> ·在profile文g末尾加入Q?<br /> export <img id="0" anchorname="baidusnap2" src="/CuteSoft_Client/CuteEditor/Images/anchor.gif" alt="" /><strong>JAVA_HOME</strong>=/usr/share/jdk1.6.0_14 <br /> export PATH=$<strong>JAVA_HOME</strong>/bin:$PATH <br /> export CLASSPATH=.:$<strong>JAVA_HOME</strong>/lib/dt.jar:$<strong>JAVA_HOME</strong>/lib/tools.jar</p> <p>·重新d <br /> ·注解 <br /> a. 你要?/usr/share/jdk1.6.0_14改ؓ你的jdk安装目录 <br /> b. <strong>linux</strong>下用冒号“:”来分隔\?<br /> c. $PATH / $CLASSPATH / $<strong>JAVA_HOME</strong> 是用来引用原来的环境变量的?<br /> ?strong>讄</strong>环境变量时特别要注意不能把原来的值给覆盖掉了Q这是一U?<br /> 常见的错误?<br /> d. CLASSPATH中当前目?#8220;.”不能?把当前目录丢掉也是常见的错误?<br /> e. export是把q三个变量导Zؓ全局变量?<br /> f. 大小写必M格区分?/p> <p>2. 修改.<img id="1" anchorname="baidusnap5" src="/CuteSoft_Client/CuteEditor/Images/anchor.gif" alt="" /><strong>bash_profile</strong>文g</p> <p>q种Ҏ更ؓ安全Q它可以把用这些环境变量的权限控制?strong>用户</strong>U别Q如果你需要给某个<strong>用户</strong>权限使用q些环境变量Q你只需要修改其个h<strong>用户</strong>ȝ录下?<strong>bash_profile</strong>文g可以了?<br /> ·用文本编辑器打开<strong>用户</strong>目录下的.<strong>bash_profile</strong>文g <br /> ·?<strong>bash_profile</strong>文g末尾加入Q?/p> <p>export <strong>JAVA_HOME</strong>=/usr/share/jdk1.6.0_14 <br /> export PATH=$<strong>JAVA_HOME</strong>/bin:$PATH <br /> export CLASSPATH=.:$<strong>JAVA_HOME</strong>/lib/dt.jar:$<strong>JAVA_HOME</strong>/lib/tools.jar</p> <p>·重新d</p> <p>3. 直接在shell?strong>讄</strong>变量 <br /> 不赞成用这U方法,因ؓ换个shellQ你?strong>讄</strong>无效了Q因此这U方法仅仅是临时使用Q以后要使用的时候又要重?strong>讄</strong>Q比较麻烦?<br /> 只需在shelll端执行下列命oQ?<br /> export <strong>JAVA_HOME</strong>=/usr/share/jdk1.6.0_14 <br /> export PATH=$<strong>JAVA_HOME</strong>/bin:$PATH <br /> export CLASSPATH=.:$<strong>JAVA_HOME</strong>/lib/dt.jar:$<strong>JAVA_HOME</strong>/lib/tools.jar</p> </span><br /> <img src ="http://www.aygfsteel.com/keweibo/aggbug/366113.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2011-12-12 08:22 <a href="http://www.aygfsteel.com/keweibo/articles/366113.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java对象序列化数l和反序列化 http://www.aygfsteel.com/keweibo/articles/358771.htmlKeKeFri, 16 Sep 2011 02:51:00 GMThttp://www.aygfsteel.com/keweibo/articles/358771.htmlhttp://www.aygfsteel.com/keweibo/comments/358771.htmlhttp://www.aygfsteel.com/keweibo/articles/358771.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/358771.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/358771.html

package serializable;

 

import java.io.ByteArrayInputStream;

import java.io.ByteArrayOutputStream;

import java.io.ObjectInputStream;

import java.io.ObjectOutputStream;

 

public class ObjectToIO

{

    /**

     *

     * 对象?/span>Byte数组

     *

     * @param obj

     *

     * @return

     *

     * @throws Exception

     *

     */

    public static byte[] objectToBytes(Object obj) throws Exception

    {

        // logger.debug("objectToString called ");

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        ObjectOutputStream sOut = new ObjectOutputStream(out);

        sOut.writeObject(obj);

        sOut.flush();

        byte[] bytes = out.toByteArray();

        // logger.debug(bytes.toString());

        return bytes;

 

    }

 

    /**

     *

     * 字节数组转对?/span>

     * @param content

     *

     * @return

     *

     * @throws Exception

     *

     */

 

    public static Object bytesToObject(byte[] bytes) throws Exception

    {

        // logger.debug("bytesToObject called ");

        // byte?/span>object

        ByteArrayInputStream in = new ByteArrayInputStream(bytes);

        ObjectInputStream sIn = new ObjectInputStream(in);

        return sIn.readObject();

 

    }

}

轉自:http://wenku.baidu.com/view/1e0a23b465ce050876321373.html

Ke 2011-09-16 10:51 发表评论
]]>
使用responseҎ清除览器缓?/title><link>http://www.aygfsteel.com/keweibo/articles/344152.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Sat, 12 Feb 2011 09:19:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/344152.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/344152.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/344152.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/344152.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/344152.html</trackback:ping><description><![CDATA[使用responseҎ清除览器缓存:<br /> <br /> <% <br /> response.setHeader("Pragma","No-cache"); <br /> response.setHeader("Cache-Control","no-cache"); <br /> response.setDateHeader("Expires", 0); <br /> %> <img src ="http://www.aygfsteel.com/keweibo/aggbug/344152.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2011-02-12 17:19 <a href="http://www.aygfsteel.com/keweibo/articles/344152.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>config.getServletContext().getRealPath("/")q回NULL的解?/title><link>http://www.aygfsteel.com/keweibo/articles/339755.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 03 Dec 2010 14:06:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/339755.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/339755.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/339755.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/339755.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/339755.html</trackback:ping><description><![CDATA[代碼片段:        <br /> String <font style="background-color: #cce8cf">prefix = config.getServletContext().getRealPath("/");<br /> <br />         if (prefix == null || prefix.equals("")) {<br />           // deployment in weblogic through ear file does not deploy<br />           // phisically<br />           // the files,<br />           // so we need to obtain the path through getClass method<br />           java.net.URL url = this.getClass().getResource("/");<br />           String mSchemaPath = url.getFile();<br />           if (mSchemaPath != null || !mSchemaPath.equals("")) {<br />             String separator = "/";<br />             int lastSlash = mSchemaPath.lastIndexOf(separator);<br />             if (lastSlash == -1) {<br />               separator = "\\";<br />               lastSlash = mSchemaPath.lastIndexOf(separator);<br />             }<br />             prefix = mSchemaPath.substring(0, lastSlash);<br />             prefix = prefix.substring(0, prefix.lastIndexOf(separator));<br />             prefix = prefix.substring(0, prefix.lastIndexOf(separator) + 1);<br />             // lastSlash = mSchemaPath.lastIndexOf(separator);<br />             // mSchemaPath = mSchemaPath.substring(0, lastSlash);<br />             // lastSlash = mSchemaPath.lastIndexOf(separator);<br />             // prefix = mSchemaPath.substring(0, lastSlash+1);<br />           }<br />         }</font> <img src ="http://www.aygfsteel.com/keweibo/aggbug/339755.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2010-12-03 22:06 <a href="http://www.aygfsteel.com/keweibo/articles/339755.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ServletContext Properties 操作文ghttp://www.aygfsteel.com/keweibo/articles/314996.htmlKeKeTue, 09 Mar 2010 14:19:00 GMThttp://www.aygfsteel.com/keweibo/articles/314996.htmlhttp://www.aygfsteel.com/keweibo/comments/314996.htmlhttp://www.aygfsteel.com/keweibo/articles/314996.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/314996.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/314996.htmlpackage com.apress.dwrprojects.instamail;


import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.util.Properties;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * This class deals with maintaining options, including the e-mail account.
 *
 * @author <a href="mailto:fzammetti@omnytex.com">Frank W. Zammetti</a>.
 */
public class OptionsManager {


  /**
   * Log instance.
   */
  private static Log log = LogFactory.getLog(OptionsManager.class);


  /**
   * File name of the options file.
   */
  private static final String optionsFilename = "options.properties";


  /**
   * This method retrieves the options and returns them.  If no
   * optionsFilename file is found, a 'blank' DTO is returned.
   *
   * @param  sc ServletContext associates with the request.
   * @return    An OptionsDTO containing all the stored options.
   */
  public OptionsDTO retrieveOptions(ServletContext sc) {

    // Instantiate an OptionsDTO, and by default assume it will be configured.
    // This means the application has already been configured for use.  This
    // affects what the user can do when the app is accessed initially.
    OptionsDTO options = new OptionsDTO();
    options.setConfigured(true);

    // Read in the options.
    InputStream isFeedFile =
      sc.getResourceAsStream("/WEB-INF/" + optionsFilename);

    Properties props = new Properties();
    try {
      if (isFeedFile == null) {
        throw new IOException(optionsFilename + " not found");
      }
      props.load(isFeedFile);
      isFeedFile.close();
    } catch (IOException e) {
      log.info("No " + optionsFilename + " file, a blank DTO will " +
        "be returned.");
      // Make sure the OptionsDTO is set as unconfigured so that when the
      // index.jsp page is loaded, all the user will be allowed to do is go to
      // the Options views.
      options.setConfigured(false);
      props.setProperty("pop3Server", "");
      props.setProperty("pop3ServerRequiresLogin", "false");
      props.setProperty("pop3Username", "");
      props.setProperty("pop3Password", "");
      props.setProperty("smtpServer", "");
      props.setProperty("smtpServerRequiresLogin", "false");
      props.setProperty("smtpUsername", "");
      props.setProperty("smtpPassword", "");
      props.setProperty("fromAddress", "");
    }

    // Populate OptionsDTO from options Properties.
    options.setPop3Server(props.getProperty("pop3Server"));
    options.setPop3ServerRequiresLogin(
      props.getProperty("pop3ServerRequiresLogin"));
    options.setPop3Username(props.getProperty("pop3Username"));
    options.setPop3Password(props.getProperty("pop3Password"));
    options.setSmtpServer(props.getProperty("smtpServer"));
    options.setSmtpServerRequiresLogin(
      props.getProperty("smtpServerRequiresLogin"));
    options.setSmtpUsername(props.getProperty("smtpUsername"));
    options.setSmtpPassword(props.getProperty("smtpPassword"));
    options.setFromAddress(props.getProperty("fromAddress"));

    return options;

  } // End retrieveOptions().


  /**
   * This method saves the options.
   *
   * @param  pop3Server              The POP3 server address.
   * @param  pop3ServerRequiresLogin Does the POP3 server require login?
   * @param  pop3Username            The POP3 username.
   * @param  pop3Password            The POP3 password.
   * @param  smtpServer              The SMTP server address.
   * @param  smtpServerRequiresLogin Does the SMTP server require login?
   * @param  smtpUsername            The SMTP username.
   * @param  smtpPassword            The SMTP password.
   * @param  fromAddress             From address for outgoing messages.
   * @param  sc                      ServletContext associated with the request.
   * @return                         A message saying the save was OK.
   */
  public String saveOptions(String pop3Server, String pop3ServerRequiresLogin,
    String pop3Username, String pop3Password, String smtpServer,
    String smtpServerRequiresLogin, String smtpUsername,
    String smtpPassword, String fromAddress, ServletContext sc) {

      // Log what we received.
      log.info("\nSaving options:\n" +
      "pop3Server = " + pop3Server + "\n" +
        "pop3ServerRequiresLogin = " + pop3ServerRequiresLogin + "\n" +
        "pop3Username = " + pop3Username + "\n" +
        "pop3Password = " + pop3Password + "\n" +
        "smtpServer = " + smtpServer + "\n" +
        "smtpServerRequiresLogin = " + smtpServerRequiresLogin + "\n" +
        "smtpUsername = " + smtpUsername + "\n" +
        "smtpPassword = " + smtpPassword + "\n" +
        "fromAddress = " + fromAddress + "\n");

      String result = "";

      // Populate Properties structure.
      Properties props = new Properties();
      props.setProperty("pop3Server", pop3Server);
      props.setProperty("pop3ServerRequiresLogin",
        pop3ServerRequiresLogin);
      props.setProperty("pop3Username", pop3Username);
      props.setProperty("pop3Password", pop3Password);
      props.setProperty("smtpServer", smtpServer);
      props.setProperty("smtpServerRequiresLogin",
        smtpServerRequiresLogin);
      props.setProperty("smtpUsername", smtpUsername);
      props.setProperty("smtpPassword", smtpPassword);
      props.setProperty("fromAddress",  fromAddress);

      // Lastly, delete any existing optionsFilename file in WEB-INF and
      // write out a new version from the Properties object we just populated.
      // Return a message saying the operation was complete, or if any problems
      // occur, a message saying what went wrong.
      FileOutputStream fos = null;
      try {
        new File(sc.getRealPath("WEB-INF") + "/" + optionsFilename).delete();
        fos = new FileOutputStream(sc.getRealPath("WEB-INF") +
          "/" + optionsFilename);
        props.store(fos, null);
        fos.flush();
        result = "Options have been saved.";

      } catch (IOException e) {
        log.error("Error saving contact:");
        e.printStackTrace();
        result = "Options could not be saved.  " +
          "Please review logs for details.";
      } finally {
        try {
          if (fos != null) {
            fos.close();
          }
        } catch (IOException e) {
          log.error("Error closing fos: " + e);
        }
      }

      return result;

  } // End saveOptions().


} // End class.



Ke 2010-03-09 22:19 发表评论
]]>
日記過濾?/title><link>http://www.aygfsteel.com/keweibo/articles/306766.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Mon, 21 Dec 2009 02:35:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/306766.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/306766.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/306766.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/306766.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/306766.html</trackback:ping><description><![CDATA[<code><font color="#7f0055"><strong>轉自:http://www.java2s.com/CN/Code/Java/Servlets/LoggingFilter.htm<br /> import </strong></font><font color="#000000">java.io.*;</font><br /> <font color="#7f0055"><strong>import </strong></font><font color="#000000">javax.servlet.*;</font><br /> <font color="#7f0055"><strong>import </strong></font><font color="#000000">javax.servlet.http.*;</font><br /> <br /> <font color="#7f0055"><strong>public final class </strong></font><font color="#000000">LoggingFilter </font><font color="#7f0055"><strong>implements </strong></font><font color="#000000">Filter </font><br /> <font color="#000000">{</font><br /> <font color="#ffffff">  </font><font color="#7f0055"><strong>private </strong></font><font color="#000000">FilterConfig filterConfig = </font><font color="#7f0055"><strong>null</strong></font><font color="#000000">;</font><br /> <br /> <font color="#ffffff">  </font><font color="#7f0055"><strong>public </strong></font><font color="#7f0055"><strong>void </strong></font><font color="#000000">doFilter</font><font color="#000000">(</font><font color="#000000">ServletRequest request, ServletResponse response,</font><br /> <font color="#ffffff">    </font><font color="#000000">FilterChain chain</font><font color="#000000">)</font><br /> <font color="#ffffff">    </font><font color="#7f0055"><strong>throws </strong></font><font color="#000000">IOException, ServletException </font><br /> <font color="#ffffff">  </font><font color="#000000">{</font><br /> <br /> <font color="#ffffff">    </font><font color="#7f0055"><strong>long </strong></font><font color="#000000">start = System.currentTimeMillis</font><font color="#000000">()</font><font color="#000000">;</font><br /> <font color="#ffffff">    </font><font color="#000000">String address =  request.getRemoteAddr</font><font color="#000000">()</font><font color="#000000">;</font><br /> <font color="#ffffff">    </font><font color="#000000">String file = </font><font color="#000000">((</font><font color="#000000">HttpServletRequest</font><font color="#000000">) </font><font color="#000000">request</font><font color="#000000">)</font><font color="#000000">.getRequestURI</font><font color="#000000">()</font><font color="#000000">;</font><br /> <font color="#ffffff">        </font><br /> <font color="#ffffff">    </font><font color="#000000">chain.doFilter</font><font color="#000000">(</font><font color="#000000">request, response</font><font color="#000000">)</font><font color="#000000">;</font><br /> <br /> <font color="#ffffff">    </font><font color="#000000">filterConfig.getServletContext</font><font color="#000000">()</font><font color="#000000">.log</font><font color="#000000">(</font><br /> <font color="#ffffff">        </font><font color="#2a00ff">"User access! " </font><font color="#000000">+      </font><br /> <font color="#ffffff">        </font><font color="#2a00ff">" User IP: " </font><font color="#000000">+ address +      </font><br /> <font color="#ffffff">        </font><font color="#2a00ff">" Resource: " </font><font color="#000000">+ file + </font><br /> <font color="#ffffff">        </font><font color="#2a00ff">" Milliseconds used: " </font><font color="#000000">+ </font><font color="#000000">(</font><font color="#000000">System.currentTimeMillis</font><font color="#000000">() </font><font color="#000000">- start</font><font color="#000000">) </font><br /> <font color="#ffffff">    </font><font color="#000000">)</font><font color="#000000">;</font><br /> <font color="#ffffff">  </font><font color="#000000">}</font><br /> <br /> <font color="#ffffff">  </font><font color="#7f0055"><strong>public </strong></font><font color="#7f0055"><strong>void </strong></font><font color="#000000">destroy</font><font color="#000000">() { }</font><br /> <br /> <font color="#ffffff">  </font><font color="#7f0055"><strong>public </strong></font><font color="#7f0055"><strong>void </strong></font><font color="#000000">init</font><font color="#000000">(</font><font color="#000000">FilterConfig filterConfig</font><font color="#000000">) {</font><br /> <font color="#ffffff">    </font><font color="#7f0055"><strong>this</strong></font><font color="#000000">.filterConfig = filterConfig;</font><br /> <font color="#ffffff">  </font><font color="#000000">}</font><br /> <font color="#000000">}</font></code> <img src ="http://www.aygfsteel.com/keweibo/aggbug/306766.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2009-12-21 10:35 <a href="http://www.aygfsteel.com/keweibo/articles/306766.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring注解入门(?http://www.aygfsteel.com/keweibo/articles/295152.htmlKeKeTue, 15 Sep 2009 07:20:00 GMThttp://www.aygfsteel.com/keweibo/articles/295152.htmlhttp://www.aygfsteel.com/keweibo/comments/295152.htmlhttp://www.aygfsteel.com/keweibo/articles/295152.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/295152.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/295152.html

轉自Qhttp://blog.csdn.net/huxin1/archive/2008/12/31/3669583.aspx
document.body.oncopy = function() { if (window.clipboardData) { setTimeout(function() { var text = clipboardData.getData("text"); if (text && text.length>300) { text = text + "\r\n\n本文来自CSDN博客Q{载请标明出处Q? + location.href; clipboardData.setData("text", text); } }, 100); } } 1. 使用Spring注解来注入属?
1.1. 使用注解以前我们是怎样注入属性的
cȝ实现Q?
  1. public class UserManagerImpl implements UserManager {   
  2.     private UserDao userDao;   
  3.     public void setUserDao(UserDao userDao) {   
  4.         this.userDao = userDao;   
  5.     }   
  6.     ...   
  7. }  

配置文gQ?
Java代码
  1. <bean id="userManagerImpl" class="com.kedacom.spring.annotation.service.UserManagerImpl">   
  2.     <property name="userDao" ref="userDao" />   
  3. </bean>   
  4. <bean id="userDao" class="com.kedacom.spring.annotation.persistence.UserDaoImpl">   
  5.     <property name="sessionFactory" ref="mySessionFactory" />   
  6. </bean>  


1.2. 引入@Autowired注解Q不推荐使用Q徏议用@ResourceQ?
cȝ实现Q对成员变量q行标注Q?
Java代码 复制代码
  1. public class UserManagerImpl implements UserManager {   
  2.     @Autowired  
  3.     private UserDao userDao;   
  4.     ...   
  5. }  

或者(Ҏ法进行标注)
Java代码 复制代码
  1. public class UserManagerImpl implements UserManager {   
  2.     private UserDao userDao;   
  3.     @Autowired  
  4.     public void setUserDao(UserDao userDao) {   
  5.         this.userDao = userDao;   
  6.     }   
  7.     ...   
  8. }  

配置文g
Java代码 复制代码
  1. <bean id="userManagerImpl" class="com.kedacom.spring.annotation.service.UserManagerImpl" />   
  2. <bean id="userDao" class="com.kedacom.spring.annotation.persistence.UserDaoImpl">   
  3.     <property name="sessionFactory" ref="mySessionFactory" />   
  4. </bean>  

@Autowired可以Ҏ员变量、方法和构造函数进行标注,来完成自动装配的工作。以上两U不同实现方? 中,@Autowired的标注位|不同,它们都会在Spring在初始化userManagerImplq个beanӞ自动装配userDaoq个? 性,区别是:W一U实CQSpring会直接将UserDaocd的唯一一个bean赋值给userDaoq个成员变量Q第二种实现中,Spring? 调用setUserDaoҎ来将UserDaocd的唯一一个bean装配到userDaoq个属性?

1.3. 让@Autowired工作h
要@Autowired能够工作Q还需要在配置文g中加入以下代?
Java代码 复制代码
  1. <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />  


1.4. @Qualifier
@Autowired是根据类型进行自动装配的。在上面的例子中Q如果当 Spring上下文中存在不止一个UserDaocd的beanӞ׃抛出BeanCreationException异常Q如果Spring上下文中 不存在UserDaocd的beanQ也会抛出BeanCreationException异常。我们可以用@Qualifier配合 @Autowired来解册些问题?
1. 可能存在多个UserDao实例
Java代码 复制代码
  1. @Autowired  
  2. public void setUserDao(@Qualifier("userDao") UserDao userDao) {   
  3.     this.userDao = userDao;   
  4. }  

q样QSpring会找到id为userDao的beanq行装配?
2. 可能不存在UserDao实例

Java代码 复制代码
  1. @Autowired(required = false)   
  2. public void setUserDao(UserDao userDao) {   
  3.     this.userDao = userDao;   
  4. }  


1.5. @ResourceQJSR-250标准注解Q推荐用它来代替Spring专有的@Autowired注解Q?
Spring 不但支持自己定义的@Autowired注解Q还支持几个由JSR-250规范定义的注解,它们分别是@Resource、@PostConstruct以及@PreDestroy?
@Resource 的作用相当于@AutowiredQ只不过@Autowired按byType自动注入Q而@Resource默认按byName自动注入|了? @Resource有两个属性是比较重要的,分别是name和typeQSpring@Resource注解的name属性解析ؓbean的名字,? type属性则解析为bean的类型。所以如果用name属性,则用byName的自动注入策略,而用type属性时则用byType自动注入{? 略。如果既不指定name也不指定type属性,q时通过反射机制使用byName自动注入{略?
@Resource装配序
  1. 如果同时指定了name和typeQ则从Spring上下文中扑ֈ唯一匚w的beanq行装配Q找不到则抛出异?
  2. 如果指定了nameQ则从上下文中查扑֐UͼidQ匹配的beanq行装配Q找不到则抛出异?
  3. 如果指定了typeQ则从上下文中找到类型匹配的唯一beanq行装配Q找不到或者找到多个,都会抛出异常
  4. 如果既没有指定nameQ又没有指定typeQ则自动按照byName方式q行装配Q见2Q;如果没有匚wQ则回退Z个原始类型(UserDaoQ进行匹配,如果匚w则自动装配;


1.6. @PostConstructQJSR-250Q?
在方法上加上注解@PostConstructQ这个方法就会在Bean初始化之后被Spring容器执行Q注QBean初始化包括,实例化BeanQƈ装配Bean的属性(依赖注入Q)?
它的一个典型的应用场景是,当你需要往Bean里注入一个其父类中定义的属性,而你又无法复写父cȝ属性或属性的setterҎӞ如:
Java代码 复制代码
  1. public class UserDaoImpl extends HibernateDaoSupport implements UserDao {   
  2.     private SessionFactory mySessionFacotry;   
  3.     @Resource  
  4.     public void setMySessionFacotry(SessionFactory sessionFacotry) {   
  5.         this.mySessionFacotry = sessionFacotry;   
  6.     }   
  7.     @PostConstruct  
  8.     public void injectSessionFactory() {   
  9.         super.setSessionFactory(mySessionFacotry);   
  10.     }   
  11.     ...   
  12. }  

q里通过@PostConstructQؓUserDaoImpl的父c里定义的一个sessionFactoryU有属性,注入? 我们自己定义的sessionFactoryQ父cȝsetSessionFactoryҎ为finalQ不可复写)Q之后我们就可以通过调用 super.getSessionFactory()来访问该属性了?

1.7. @PreDestroyQJSR-250Q?
在方法上加上注解@PreDestroyQ这个方法就会在Bean初始化之后被Spring容器执行。由于我们当前还没有需要用到它的场景,q里不不LC。其用法同@PostConstruct?

1.8. 使用<context:annotation-config />化配|?
Spring2.1 d了一个新的context的Schema命名I间Q该命名I间Ҏ释驱动、属性文件引入、加载期l入{功能提供了便捷的配|。我们知道注释本w是不会 做Q何事情的Q它仅提供元数据信息。要使元数据信息真正起作用,必须让负责处理这些元数据的处理器工作h?
AutowiredAnnotationBeanPostProcessor 和CommonAnnotationBeanPostProcessor是处理q些注释元数据的处理器。但是直接在Spring配置文g中定义这? Bean昑־比较W拙。Spring为我们提供了一U方便的注册q些BeanPostProcessor的方式,q就 ?lt;context:annotation-config />Q?
Java代码 复制代码
  1. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  2.     xsi:schemaLocation="http://www.springframework.org/schema/beans   
  3.     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
  4.     http://www.springframework.org/schema/context   
  5.     http://www.springframework.org/schema/context/spring-context-2.5.xsd">   
  6.     <context:annotation-config />   
  7. </beans>  

<context:annotationconfig />隐式地向Spring容器注册AutowiredAnnotationBeanPostProcessor? CommonAnnotationBeanPostProcessor? PersistenceAnnotationBeanPostProcessor以及 RequiredAnnotationBeanPostProcessorq?个BeanPostProcessor?

2. 使用Spring注解完成Bean的定?
以上我们介绍了通过@Autowired或@Resource来实现在Bean中自动注入的功能Q下面我们将介绍如何注解BeanQ从而从XML配置文g中完全移除Bean定义的配|?

2.1. @ComponentQ不推荐使用Q、@Repository、@Service、@Controller
只需要在对应的类上加上一个@Component注解Q就该cd义ؓ一个Bean了:
Java代码 复制代码
  1. @Component  
  2. public class UserDaoImpl extends HibernateDaoSupport implements UserDao {   
  3.     ...   
  4. }  

使用@Component注解定义的BeanQ默认的名称QidQ是写开头的非限定类名。如q里定义的Bean名称是userDaoImpl。你也可以指定Bean的名Uͼ
@Component("userDao")
@Component 是所有受Spring理lg的通用形式QSpringq提供了更加l化的注解Ş式:@Repository、@Service? @ControllerQ它们分别对应存储层BeanQ业务层BeanQ和展示层Bean。目前版本(2.5Q中Q这些注解与@Component的语? 是一LQ完全通用Q在Spring以后的版本中可能会给它们q加更多的语义。所以,我们推荐使用@Repository、@Service? @Controller来替代@Component?

2.2. 使用<context:component-scan />让Bean定义注解工作h
Java代码 复制代码
  1. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  2.     xsi:schemaLocation="http://www.springframework.org/schema/beans   
  3.     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
  4.     http://www.springframework.org/schema/context   
  5.     http://www.springframework.org/schema/context/spring-context-2.5.xsd">   
  6.     <context:component-scan base-package="com.kedacom.ksoa" />   
  7. </beans>  

q里Q所有通过<bean>元素定义Bean的配|内容已l被U除Q仅需要添加一 ?lt;context:component-scan />配置px有问题了——Spring XML配置文g得到了极致的化(当然配置元数据还是需要的Q只不过以注释Ş式存在Ş了)?lt;context:component-scan />的base-package属性指定了需要扫描的cdQ类包及光归子包中所有的c都会被处理?
<context:component-scan />q允许定义过滤器基包下的某些类U_或排除。Spring支持以下4U类型的qo方式Q?
  • qo器类?表达式范?说明
  • 注解 org.example.SomeAnnotation 所有用SomeAnnotation注解的类qo出来
  • cd指定 org.example.SomeClass qo指定的类
  • 正则表达?com\.kedacom\.spring\.annotation\.web\..* 通过正则表达式过滤一些类
  • AspectJ表达?org.example..*Service+ 通过AspectJ表达式过滤一些类

以正则表辑ּZQ我列D一个应用实例:
Java代码 复制代码
  1. <context:component-scan base-package="com.casheen.spring.annotation">   
  2.     <context:exclude-filter type="regex" expression="com\.casheen\.spring\.annotation\.web\..*" />   
  3. </context:component-scan>  

值得注意的是<context:component-scan />配置不但启用了对类包进行扫描以实施注释驱动Bean定义的功能,同时q启用了注释驱动自动注入的功能(卌隐式地在内部注册? AutowiredAnnotationBeanPostProcessor和CommonAnnotationBeanPostProcessorQ, 因此当?lt;context:component-scan />后,可以将<context:annotation-config />U除了?

2.3. 使用@Scope来定义Bean的作用范?
在用XML定义BeanӞ我们可能q需要通过bean的scope属性来定义一个Bean的作用范_我们同样可以通过@Scope注解来完成这工作:
Java代码 复制代码
  1. @Scope("session")   
  2. @Component()   
  3. public class UserSessionBean implements Serializable {   
  4.     ...   
  5. }  


3. 参?
http://kingtai168.javaeye.com/blog/244002
http://www.javaeye.com/topic/244153
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-annotation-config
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-classpath-scanning



Ke 2009-09-15 15:20 发表评论
]]>AWT l习 - 播放声音文g AudioPlayer.java(?http://www.aygfsteel.com/keweibo/articles/290153.htmlKeKeThu, 06 Aug 2009 12:18:00 GMThttp://www.aygfsteel.com/keweibo/articles/290153.htmlhttp://www.aygfsteel.com/keweibo/comments/290153.htmlhttp://www.aygfsteel.com/keweibo/articles/290153.html#Feedback2http://www.aygfsteel.com/keweibo/comments/commentRss/290153.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/290153.html文g來源Qhttp://www.aygfsteel.com/beansoft/archive/2007/06/27/126550.html
/*
 * @(#)AudioPlayer.java 1.0 03/04/17
 *
 
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.applet.AudioClip;
//{{{ Declares!
class test {
}
//}}}
public class AudioPlayer
    
extends Frame {
  AudioClip clip 
= null;
  FileDialog dialog 
= new FileDialog(this);
  Label labelCopyright 
= new Label();
  TextField textFieldFileName 
= new TextField();
  Panel panel1 
= new Panel();
  Button buttonOpen 
= new Button();
  Button buttonPlay 
= new Button();
  Button buttonLoop 
= new Button();
  Button buttonStop 
= new Button();

  
public AudioPlayer() {
    setTitle(
"AudioPlayer");
    addWindowListener(
new WindowAdapter() {
      
public void windowClosing(WindowEvent e) {
        dispose();
        System.exit(
0);
      }
    }
    );
    
try {
      jbInit();
    }
    
catch (Exception e) {
      e.printStackTrace();
    }
    pack();
    setVisible(
true);
  }

  
private void jbInit() throws Exception {
    labelCopyright.setBackground(Color.darkGray);
    labelCopyright.setForeground(Color.orange);
    labelCopyright.setText(
        
"Copyright (c) 2003 BeanSoft Studio. All rights reserved.");
    
this.setTitle("Java Audio Player");
    textFieldFileName.setEditable(
false);
    buttonOpen.setLabel(
"打开");
    buttonOpen.addActionListener(
new java.awt.event.ActionListener() {
      
public void actionPerformed(ActionEvent e) {
        buttonOpen_actionPerformed(e);
      }
    }
    );
    buttonPlay.setLabel(
"播放");
    buttonPlay.addActionListener(
new java.awt.event.ActionListener() {
      
public void actionPerformed(ActionEvent e) {
        play();
      }
    }
    );
    buttonLoop.setLabel(
"循环");
    buttonLoop.addActionListener(
new java.awt.event.ActionListener() {
      
public void actionPerformed(ActionEvent e) {
        loop();
      }
    }
    );
    buttonStop.setLabel(
"停止");
    buttonStop.addActionListener(
new java.awt.event.ActionListener() {
      
public void actionPerformed(ActionEvent e) {
        stop();
      }
    }
    );
    
this.add(labelCopyright, BorderLayout.SOUTH);
    
this.add(textFieldFileName, BorderLayout.NORTH);
    
this.add(panel1, BorderLayout.CENTER);
    panel1.add(buttonOpen, 
null);
    panel1.add(buttonPlay, 
null);
    panel1.add(buttonLoop, 
null);
    panel1.add(buttonStop, 
null);
  }

  
public AudioClip getAudioClip() {
    
return this.clip;
  }

  
public void setAudioClip(AudioClip clip) {
    
this.clip = clip;
  }

  
public static void main(String args[]) {
    
new AudioPlayer();
  }

  
void buttonOpen_actionPerformed(ActionEvent e) {
    stop();
    dialog.show();
    
if (dialog.getFile() != null) {
      String filename 
= dialog.getDirectory() + dialog.getFile();
      
try {
        setAudioClip(Applet.newAudioClip( (
new java.io.File(filename)).toURL()));
      }
      
catch (Exception ex) {
        ex.printStackTrace();
      }

      textFieldFileName.setText(filename);
    }
    play();
  }

  
void play() {
    
if (getAudioClip() != null) {
      getAudioClip().play();
    }
  }

  
void loop() {
    
if (getAudioClip() != null) {
      getAudioClip().loop();
    }
  }

  
void stop() {
    
if (getAudioClip() != null) {
      getAudioClip().stop();
    }
  }
}


Ke 2009-08-06 20:18 发表评论
]]>
Java调用Oracle函数http://www.aygfsteel.com/keweibo/articles/270153.htmlKeKeTue, 12 May 2009 02:27:00 GMThttp://www.aygfsteel.com/keweibo/articles/270153.htmlhttp://www.aygfsteel.com/keweibo/comments/270153.htmlhttp://www.aygfsteel.com/keweibo/articles/270153.html#Feedback2http://www.aygfsteel.com/keweibo/comments/commentRss/270153.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/270153.html 

调用无入参的函数

函数定义

CREATE OR REPLACE Function f_getstring Return Varchar2 Is
Begin
 Return ''String value'';
End f_getstring;

调用函数的Java片断

   CallableStatement cstmt = con.prepareCall("{?=call f_getstring}");
   cstmt.registerOutParameter(1, Types.VARCHAR);
   cstmt.execute();
   String strValue = cstmt.getString(1);
   System.out.println("The return value is:" + strValue);
   cstmt.close();

调用有一个入参,一个输出参C及一个字W串q回值的函数

函数定义

CREATE OR REPLACE Function f_Getinfo(Id Integer, Age Out Integer) Return Varchar2 Is
Begin
 Age := 10;
 Return ''The age is:'' || Id;
End f_Getinfo;

调用函数的Java代码片断

   CallableStatement cstmt = con
     .prepareCall("{?=call f_getinfo(?,?)}");
   cstmt.registerOutParameter(1, Types.VARCHAR);
   cstmt.setInt(2, 11);
   cstmt.registerOutParameter(3, Types.INTEGER);
   cstmt.execute();
   String strValue = cstmt.getString(1);
   int age = cstmt.getInt(3);
   System.out.println("The return value is:" + strValue
     + " and age is:" + age);
   cstmt.close();



Ke 2009-05-12 10:27 发表评论
]]>
URLConnection在类里执行URLhttp://www.aygfsteel.com/keweibo/articles/261028.htmlKeKeFri, 20 Mar 2009 05:49:00 GMThttp://www.aygfsteel.com/keweibo/articles/261028.htmlhttp://www.aygfsteel.com/keweibo/comments/261028.htmlhttp://www.aygfsteel.com/keweibo/articles/261028.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/261028.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/261028.htmlpackage SFIS.DB;
import java.net.MalformedURLException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class URLConnectionTest {
public static void main(String []args){
try {
long begintime = System.currentTimeMillis();
URL url = new URL("http://10.240.19.112:8080/quartz/jobs/executeJob.action?jobName=NOTEPAD_JOB&jobGroup=DEFAULT");

HttpURLConnection urlcon = (HttpURLConnection)url.openConnection();
System.out.println(urlcon.getResponseCode());
urlcon.connect();

//InputStream is = urlcon.getInputStream();
/*InputStream is = urlcon.getErrorStream();
if(null != is) {
BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
StringBuffer bs = new StringBuffer();
String l = null;
while((l=buffer.readLine())!=null){
bs.append(l).append("\n");
}
System.out.println(bs.toString());
is.close();
} else if (null == is) {
System.out.println("Null");
} else {
System.out.println("UNKNOW...");
}*/
//System.out.println(" content-encodeQ?+urlcon.getContentEncoding());
//System.out.println(" content-lengthQ?+urlcon.getContentLength());
//System.out.println(" content-typeQ?+urlcon.getContentType());
//System.out.println(" dateQ?+urlcon.getDate());
System.out.println("total timeQ?+(System.currentTimeMillis()-begintime)+"毫秒");
urlcon.disconnect();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}


Ke 2009-03-20 13:49 发表评论
]]>
JAVA如何调用DOS命o http://www.aygfsteel.com/keweibo/articles/208405.htmlKeKeMon, 16 Jun 2008 10:57:00 GMThttp://www.aygfsteel.com/keweibo/articles/208405.htmlhttp://www.aygfsteel.com/keweibo/comments/208405.htmlhttp://www.aygfsteel.com/keweibo/articles/208405.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/208405.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/208405.html文章來源Q?a style="color: red" href="http://www.aygfsteel.com/leeguannan/archive/2007/11/29/164044.html">http://www.aygfsteel.com/leeguannan/archive/2007/11/29/164044.html

用Java~写应用Ӟ有时需要在E序中调用另一个现成的可执行程序或pȝ命oQ这时可以通过l合使用Java提供的RuntimecdProcesscȝҎ实现。下面是一U比较典型的E序模式Q?
...
Process process = Runtime.getRuntime().exec(".\\p.exe");
process.waitfor( );
...
在上面的E序中,W一行的“.\\p.exe”是要执行的程序名QRuntime.getRuntime()q回当前应用E序的Runtime对象Q该对象的exec()Ҏ指示Java虚拟机创Z个子q程执行指定的可执行E序Qƈq回与该子进E对应的Process对象实例。通过Process可以控制该子q程的执行或获取该子q程的信息。第二条语句的目的等待子q程完成再往下执行?
但在windowsq_上,如果处理不当Q有时ƈ不能得到预期的结果。下面是W者在实际~程中ȝ的几U需要注意的情况Q?
1、执行DOS的内部命?
如果要执行一条DOS内部命oQ有两种Ҏ。一U方法是把命令解释器包含在exec()的参C。例如,执行dir命oQ在NT上, 可写成exec("cmd.exe /c dir")Q在windows 95/98下,可写?#8220;command.exe /c dir”Q其中参?#8220;/c”表示命o执行后关闭Dos立即关闭H口。另一U方法是Q把内部命o攑֜一个批命omy_dir.bat文g中,在JavaE序中写成exec("my_dir.bat")。如果仅仅写成exec("dir")QJava虚拟机则会报q行旉误。前一U方法要保证E序的可UL性,需要在E序中读取运行的操作pȝq_Q以调用不同的命令解释器。后一U方法则不需要做更多的处理?
2、打开一个不可执行的文g
打开一个不可执行的文gQ但该文件存在关联的应用E序Q则可以有两U方式?以打开一个word文档a.doc文gZQJava中可以有以下两种写法Q?
exec("start .\\a.doc");
exec(" c:\\Program Files\\Microsoft Office\\office\\winword.exe .\\a.doc");
昄Q前一U方法更为简hѝ?
3、执行一个有标准输出的DOS可执行程?
在windowsq_上,q行被调用程序的DOSH口在程序执行完毕后往往q不会自动关闭,从而导致Java应用E序d在waitfor( )。导致该现象的一个可能的原因是,该可执行E序的标准输出比较多Q而运行窗口的标准输出~冲Z够大。解决的办法是,利用Java提供的ProcesscL供的Ҏ让Java虚拟机截莯调用E序的DOSq行H口的标准输出,在waitfor()命o之前dH口的标准输出缓冲区中的内容。一D典型的E序如下Q?
...
String ls_1;
Process process = Runtime.getRuntime().exec("cmd /c dir \\windows");
BufferedReader bufferedReader = new BufferedReader( \
new InputStreamReader(process.getInputStream());
while ( (ls_1=bufferedReader.readLine()) != null)
System.out.println(ls_1);
?
process.waitfor( );
...

以上内容{载~下面内容为原创!

今天在做客户端程序的自动更新Q简单描qC下,是从服务器上将更新包下载下来,然后在本地解压羃Q最后删掉~功能很简单~

但是问题出在使用JAVA的ZIP模块做文件的解压~不是想象的那么单,资源需要释放,一个不心没有办法删除掉原有ZIP文g了~资源的占用确实是个大问题Q但是好在,客户端程序更新完是要重启的,一切都烟消云散了~对于删除不掉ZIP文g的问题,我也氓一下~用DEL删除~此处一定要注意Q?/p>

Process process = Runtime.getRuntime().exec("cmd /c del f:\\aaa.doc");
q样的调用是没有问题~

Process process = Runtime.getRuntime().exec("del f:\\aaa.doc");
q样写是不可能对的~

记录一下,警告一下后人!



Ke 2008-06-16 18:57 发表评论
]]>
Java中的内部cd匿名c?/title><link>http://www.aygfsteel.com/keweibo/articles/161140.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Fri, 16 Nov 2007 14:57:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/161140.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/161140.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/161140.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/161140.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/161140.html</trackback:ping><description><![CDATA[内部c?一个内部类的定义是定义在另一个内部的cR?br /> 原因?<br /> 1.一个内部类的对象能够访问创建它的对象的实现Q包括私有数据?br /> 2.对于同一个包中的其他cL_内部c能够隐藏v来?br /> 3.匿名内部cd以很方便的定义回调?br /> 4.使用内部cd以非常方便的~写事g驱动E序?br /> <br /> 提vJava内部c(Inner ClassQ可能很多h不太熟悉Q实际上cM的概念在C++里也有,那就是嵌套类QNested ClassQ,关于q两者的区别与联p,在下文中会有Ҏ。内部类从表面上看,是在类中又定义了一个类Q下文会看到Q内部类可以在很多地方定义)Q而实 际上q没有那么简单,乍看上去内部cM乎有些多余,它的用处对于初学者来说可能ƈ不是那么显著Q但是随着对它的深入了解,你会发现Java的设计者在内部 cn上的是用心良苦。学会用内部类Q是掌握Java高~程的一部分Q它可以让你更优雅地设计你的E序l构。下面从以下几个斚w来介l:<br /> <br /> * W一ơ见?br /> <br /> public interface Contents {<br /> int value();<br /> }<br /> <br /> public interface Destination {<br /> String readLabel();<br /> }<br /> <br /> public class Goods {<br /> private class Content implements Contents {<br /> private int i = 11;<br /> public int value() {<br /> return i;<br /> }<br /> }<br /> <br /> protected class GDestination implements Destination {<br /> private String label;<br /> private GDestination(String whereTo) {<br /> label = whereTo;<br /> }<br /> public String readLabel() {<br /> return label;<br /> }<br /> }<br /> <br /> public Destination dest(String s) {<br /> return new GDestination(s);<br /> }<br /> public Contents cont() {<br /> return new Content();<br /> }<br /> }<br /> <br /> class TestGoods {<br /> public static void main(String[] args) {<br /> Goods p = new Goods();<br /> Contents c = p.cont();<br /> Destination d = p.dest("Beijing");<br /> }<br /> }<br /> 在这个例子里cContent和GDestination被定义在了类Goods内部Qƈ且分别有着protected和private修饰W来控制讉K U别。Content代表着Goods的内容,而GDestination代表着Goods的目的地。它们分别实C两个接口Content? Destination。在后面的mainҎ里,直接?Contents c和Destination dq行操作Q你甚至q这两个内部cȝ名字都没有看见!q样Q内部类的第一个好处就体现出来??隐藏你不惌别h知道的操作,也即装性?br /> <br /> 同时Q我们也发现了在外部cM用范围之外得到内部类对象的第一个方法,那就是利用其外部cȝҎ创徏q返回。上例中的cont()和dest()Ҏ是q么做的。那么还有没有别的方法呢Q当然有Q其语法格式如下Q?br /> <br /> outerObject=new outerClass(Constructor Parameters);<br /> <br /> outerClass.innerClass innerObject=outerObject.new InnerClass(Constructor Parameters);<br /> <br /> 注意在创建非静态内部类对象Ӟ一定要先创v相应的外部类对象。至于原因,也就引出了我们下一个话??<br /> <br /> * 非静态内部类对象有着指向其外部类对象的引?br /> <br /> 对刚才的例子E作修改Q?br /> <br /> public class Goods {<br /> <br /> private valueRate=2;<br /> <br /> private class Content implements Contents {<br /> private int i = 11*valueRate;<br /> public int value() {<br /> return i;<br /> }<br /> }<br /> <br /> protected class GDestination implements Destination {<br /> private String label;<br /> private GDestination(String whereTo) {<br /> label = whereTo;<br /> }<br /> public String readLabel() {<br /> return label;<br /> }<br /> }<br /> <br /> public Destination dest(String s) {<br /> return new GDestination(s);<br /> }<br /> public Contents cont() {<br /> return new Content();<br /> }<br /> }<br /> <br /> 修改的部分用蓝色昄了。在q里我们lGoodscd加了一个private成员变量valueRateQ意义是货物的h值系敎ͼ在内部类Content 的方法value()计算价值时把它乘上。我们发玎ͼvalue()可以讉KvalueRateQ这也是内部cȝW二个好??一个内部类对象可以讉K? 建它的外部类对象的内容,甚至包括U有变量Q这是一个非常有用的Ҏ,为我们在设计时提供了更多的思\和捷径。要惛_现这个功能,内部cd象就必须有指? 外部cd象的引用? Java~译器在创徏内部cd象时Q隐式的把其外部cd象的引用也传了进dƈ一直保存着。这样就使得内部cd象始l可以访问其外部cd象,同时q也是ؓ什 么在外部cM用范围之外向要创建内部类对象必须先创建其外部cd象的原因?br /> <br /> 有h会问Q如果内部类里的一个成员变量与外部cȝ一个成员变量同名,也即外部cȝ同名成员变量被屏蔽了Q怎么办?没事QJava里用如下格式表达外部cȝ引用Q?br /> outerClass.this<br /> <br /> 有了它,我们׃怕这U屏蔽的情况了?br /> <br /> * 静态内部类<br /> <br /> 和普通的cMP内部cM可以有静态的。不q和非静态内部类相比Q区别就在于静态内部类没有了指向外部的引用。这实际上和C++中的嵌套cd相像了, Java内部cMC++嵌套cL大的不同在于是否有指向外部的引用这一点上Q当然从设计的角度以及以它一些细节来讲还有区别?br /> <br /> 除此之外Q在M非静态内部类中,都不能有静态数据,静态方法或者又一个静态内部类Q内部类的嵌套可以不止一层)。不q静态内部类中却可以拥有q一切。这也算是两者的W二个区别吧?br /> <br /> * 局部内部类 <br /> <br /> 是的QJava内部cM可以是局部的Q它可以定义在一个方法甚至一个代码块之内?br /> <br /> public class Goods1 {<br /> public Destination dest(String s) {<br /> class GDestination implements Destination {<br /> private String label;<br /> private GDestination(String whereTo) {<br /> label = whereTo;<br /> }<br /> public String readLabel() { return label; }<br /> }<br /> return new GDestination(s);<br /> }<br /> <br /> public static void main(String[] args) {<br /> Goods1 g= new Goods1();<br /> Destination d = g.dest("Beijing");<br /> }<br /> }<br /> <br /> 上面是q样一个例子。在Ҏdest中我们定义了一个内部类Q最后由q个Ҏq回q个内部cȝ对象。如果我们在用一个内部类的时候仅需要创建它的一个对象ƈ创给外部Q就可以q样做。当Ӟ定义在方法中的内部类可以使设计多样化Q用途绝不仅仅在q一炏V?br /> <br /> 下面有一个更怪的例子Q?br /> <br /> public class Goods2{<br /> private void internalTracking(boolean b) {<br /> if(b) {<br /> class TrackingSlip {<br /> private String id;<br /> TrackingSlip(String s) {<br /> id = s;<br /> }<br /> String getSlip() { return id; }<br /> }<br /> TrackingSlip ts = new TrackingSlip("slip");<br /> String s = ts.getSlip();<br /> }<br /> }<br /> <br /> public void track() { internalTracking(true); }<br /> <br /> public static void main(String[] args) {<br /> Goods2 g= new Goods2();<br /> g.track();<br /> }<br /> }<br /> <br /> 你不能在if之外创徏q个内部cȝ对象Q因已经出了它的作用域。不q在~译的时候,内部cTrackingSlip和其他类一样同时被~译Q只不过它由它自q作用域,出了这个范围就无效Q除此之外它和其他内部类q没有区别?br /> <br /> * 匿名内部c?<br /> <br /> java的匿名内部类的语法规则看上去有些古怪,不过如同匿名数组一P当你只需要创Z个类的对象而且用不上它的名字时Q用内部类可以使代码看上去z清楚。它的语法规则是q样的:<br /> new interfacename(){......}; ?new superclassname(){......};<br /> <br /> 下面接着前面l箋举例子:<br /> public class Goods3 {<br /> public Contents cont(){<br /> return new Contents(){<br /> private int i = 11;<br /> public int value() {<br /> return i;<br /> }<br /> };<br /> }<br /> }<br /> <br /> q里Ҏcont()使用匿名内部cȝ接返回了一个实C接口Contents的类的对象,看上ȝ十分简z?br /> <br /> 在java的事件处理的匿名适配器中Q匿名内部类被大量的使用。例如在惛_闭窗口时加上q样一句代码:<br /> frame.addWindowListener(new WindowAdapter(){<br /> public void windowClosing(WindowEvent e){<br /> System.exit(0);<br /> }<br /> });<br /> <br /> 有一炚w要注意的是,匿名内部cȝ于没有名字,所以它没有构造函敎ͼ但是如果q个匿名内部cȝ承了一个只含有带参数构造函数的父类Q创建它的时候必d上这些参敎ͼq在实现的过E中使用super关键字调用相应的内容Q。如果你惌初始化它的成员变量,有下面几U方法:<br /> <br /> 1. 如果是在一个方法的匿名内部c,可以利用q个Ҏ传进你想要的参数Q不q记住,q些参数必须被声明ؓfinal?br /> 2. 匿名内部类攚w成有名字的局部内部类Q这样它可以拥有构造函C?br /> 3. 在这个匿名内部类中用初始化代码块?<br /> <br /> * Z么需要内部类Q?<br /> <br /> java内部cL什么好处?Z么需要内部类Q?br /> <br /> 首先举一个简单的例子Q如果你惛_C个接口,但是q个接口中的一个方法和你构想的q个cM的一个方法的名称Q参数相同,你应该怎么办?q时候,你可以徏 一个内部类实现q个接口。由于内部类对外部类的所有内定w是可讉K的,所以这样做可以完成所有你直接实现q个接口的功能?br /> <br /> 不过你可能要质疑Q更改一下方法的不就行了吗?<br /> <br /> 的确Q以此作计内部类的理由,实在没有说服力?br /> <br /> 真正的原因是q样的,java中的内部cd接口加在一P可以的解军_被C++E序员抱怨java中存在的一个问??没有多ѝ实际上QC++的多l承设计h很复杂,而java通过内部cd上接口,可以很好的实现多l承的效果?br /> <br /> 本文的目的只是向大家介绍一下内部类的概念以及用方法,在后l文章里Q将会针Ҏ文中的内容D更多具体的例子,以及介绍如何使用内部cLZ个Applicaton Framework?<br /> <img src ="http://www.aygfsteel.com/keweibo/aggbug/161140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2007-11-16 22:57 <a href="http://www.aygfsteel.com/keweibo/articles/161140.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>单例QsingletonQ类 http://www.aygfsteel.com/keweibo/articles/156687.htmlKeKeMon, 29 Oct 2007 07:23:00 GMThttp://www.aygfsteel.com/keweibo/articles/156687.htmlhttp://www.aygfsteel.com/keweibo/comments/156687.htmlhttp://www.aygfsteel.com/keweibo/articles/156687.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/156687.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/156687.html阅读全文

Ke 2007-10-29 15:23 发表评论
]]>
JavaW记(构造方?http://www.aygfsteel.com/keweibo/articles/156673.htmlKeKeMon, 29 Oct 2007 06:41:00 GMThttp://www.aygfsteel.com/keweibo/articles/156673.htmlhttp://www.aygfsteel.com/keweibo/comments/156673.htmlhttp://www.aygfsteel.com/keweibo/articles/156673.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/156673.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/156673.html阅读全文

Ke 2007-10-29 14:41 发表评论
]]>
JavaW记(创徏对象的方?http://www.aygfsteel.com/keweibo/articles/156666.htmlKeKeMon, 29 Oct 2007 06:12:00 GMThttp://www.aygfsteel.com/keweibo/articles/156666.htmlhttp://www.aygfsteel.com/keweibo/comments/156666.htmlhttp://www.aygfsteel.com/keweibo/articles/156666.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/156666.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/156666.html 下面说说四种昑ּ的创建对象的方式:
    ?nbsp; 用new语句创徏对象
    ?nbsp; q用反射手段,调用java.lang.Class 或?java.lang.reflect.Constructor cȝnewInstance()实例Ҏ
    ?nbsp; 调用对象的clone()Ҏ
    ?nbsp; q用序列化手D?调用java.io.ObjectInputStream 对象?readObject()Ҏ.

例子

 

Customer.java

package dgut.ke.javatest;

public class Customer implements Cloneable {

 private String name;
 private int age;
 
 public Customer() {
  this("unknown",0);
  System.out.println("call default constructor");
 }
 
 public Customer(String name,int age) {
  this.name = name;
  this.age = age;
  System.out.println("call second constructor");
 }
 
 public Object clone() throws CloneNotSupportedException {
  return super.clone();
 }
 
 public boolean equals(Object o) {
  if (this == o)
   return true;
  if (! (o instanceof Customer))
   return false;
  final Customer other = (Customer) o;
  
  if (this.name.equals(other.name) && this.age == other.age)
   return true;
  else
   return false;
 }
 
 public String toString() {
  return "customer.name = "+name+" customer.age = "+age;
 }
 /**
  * @param args
  */
 public static void main(String[] args) throws Exception{
  // q用反射手段创徏Customer对象
  Class objectClass = Class.forName("dgut.ke.javatest.Customer");
  Customer c1 = (Customer) objectClass.newInstance();
  System.out.println("c1 --> " + c1);
  
  //用new创徏Customer对象
  Customer c2 = new Customer("Tom",20);
  System.out.println("c2 --> " + c2);
  
  //q用克隆手段创徏Customer对象
  Customer c3 = (Customer) c2.clone();
  System.out.println("c3 --> " + c3);
  System.out.println("c2 == c3 " + (c2==c3));
  System.out.println("c2.equals(c3) " + c2.equals(c3));
 }

}

 

ClasscȝforNameҎ

public static Class<?> forName(String className)
throws ClassNotFoundException
q回与带有给定字W串名的cL接口相关联的 Class 对象。调用此Ҏ{效于:
  Class.forName(className, true, currentLoader)
其中 currentLoader 表示此类的定义类加蝲器?

例如Q以下代码片D返?java.lang.Thread cȝq行?Class 描述W?

   Class t = Class.forName("java.lang.Thread")

调用 forName("X") 导致名?X 的类被初始化?

 

参数Q?/strong>
className - 所需cȝ完全限定名?
q回Q?/strong>
h指定名的cȝ Class 对象?
抛出Q?/strong>
LinkageError - 如果链接p|
ExceptionInInitializerError - 如果此方法所Ȁ发的初始化失?
ClassNotFoundException - 如果找不到该c?/dd>

Objectcȝclone()Ҏ

protected Object clone()
throws CloneNotSupportedException
创徏q返回此对象的一个副本?#8220;副本”的准含义可能依赖于对象的类。一般来_对于M对象 xQ如果表辑ּQ?
x.clone() != x
是正的Q则表达式:
x.clone().getClass() == x.getClass()
ؓ trueQ但q些不是l对条g。一般情况下是:
x.clone().equals(x)
ؓ trueQ但q不是绝Ҏ件?

按照惯例Q返回的对象应该通过调用 super.clone 获得。如果一个类及其所有的类Q?tt>Object 除外Q都遵守此约定,?x.clone().getClass() == x.getClass()?

按照惯例Q此Ҏq回的对象应该独立于该对象(正被克隆的对象)。要获得此独立性,?super.clone q回对象之前Q有必要对该对象的一个或多个字段q行修改。这通常意味着要复制包含正在被克隆对象的内?#8220;深层l构”的所有可变对象,q用对副本的引用替换对q些对象的引用。如果一个类只包含基本字D|对不变对象的引用Q那么通常不需要修?super.clone q回的对象中的字Dc?

Objectclone Ҏ执行特定的克隆操作。首先,如果此对象的cM能实现接?CloneableQ则会抛?CloneNotSupportedException?/span>注意Q所有的数组都被视ؓ实现接口 Cloneable。否则,此方法会创徏此对象的cȝ一个新实例Qƈ像通过分配那样Q严g用此对象相应字段的内容初始化该对象的所有字D;q些字段的内Ҏ有被自我克隆。所以,此方法执行的是该对象?#8220;表复制”Q而不“深层复制”操作?

Object cLw不实现接口 CloneableQ所以在cMؓ Object 的对象上调用 clone Ҏ会D在运行时抛出异常?

 

q回Q?/strong>
此实例的一个克隆?
抛出Q?/strong>
CloneNotSupportedException - 如果对象的类不支?Cloneable 接口Q则重写 clone Ҏ的子cM会抛出此异常Q以指示无法克隆某个实例?
另请参见Q?/strong>
Cloneable


Ke 2007-10-29 14:12 发表评论
]]>
接口的基本特?/title><link>http://www.aygfsteel.com/keweibo/articles/154753.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Sun, 21 Oct 2007 11:54:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/154753.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/154753.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/154753.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/154753.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/154753.html</trackback:ping><description><![CDATA[接口的基本特?br />   <br />  接口对其成员变量和方法做了许多限Ӟ接口的特征归U_下:<br /> <span style="color: red"><strong style="color: #000000">  <br />   (1)接口中的成员变量默认?span style="color: #ff0000">public static final</span>cd的,必须被显式的初始化?br />   (2)接口的Ҏ默认?span style="color: #ff0000">public abstract</span>cd的?br />   (3)接口<span style="color: #ff0000">没有构造方?/span>Q不能被实例化?br />   (4)一个接口不能实现另一个接口,但它可以l承多个其他接口?br />   (5)接口必须通过cL实现它的抽象ҎQ类实现接口的关键字为implements<br />   (6)与子cȝ承父cMP当类实现了某个接口时Q它必须实现接口中所有的抽象ҎQ?br />     否则q个cdMؓ抽象cR?br />   (7)不允许创建接口的实例Q但允许定义接口cd的引用变量,?span style="color: #ff0000">变量引用实现了这?br />     接口的类的实?br /> </span>  (8)一个类只能l承一个直接父c,但能实现多个接口?/strong></span> <img src ="http://www.aygfsteel.com/keweibo/aggbug/154753.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2007-10-21 19:54 <a href="http://www.aygfsteel.com/keweibo/articles/154753.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cM间的关系http://www.aygfsteel.com/keweibo/articles/154748.htmlKeKeSun, 21 Oct 2007 11:36:00 GMThttp://www.aygfsteel.com/keweibo/articles/154748.htmlhttp://www.aygfsteel.com/keweibo/comments/154748.htmlhttp://www.aygfsteel.com/keweibo/articles/154748.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/154748.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/154748.htmlcM间的关系

  UML把类之间的关pdZ?U?
  ?nbsp;Q类A与类B的实例之间存在特定的对应关系
  ?nbsp;依赖Q类A讉KcB提供的服?br />   ?nbsp;聚集Q类A为整体类Q类B为局部类Q类A的对象由cB的对象组合而成
  ?nbsp;泛化Q类Al承cB
  ?nbsp;实现Q类A实现了B接口
  
兌QAssociationQ?/strong>
  兌指的是类之间的特定对应关p,在UML中用带实U的头表示。按照类之间的数量对比,兌
可以分ؓ以下三种Q?br />   ?nbsp;一对一兌
  ?nbsp;一对多兌
  ?nbsp;多对多关?br /> 注意Q关联还要以分ؓ单向兌和双向关?/p>

依赖QDependencyQ?br />   依赖指的是类之间的调用关p,在UML中用带虚U的头表示。如果类A讉KcB的属性或者方法,
或者类A负责实例化类BQ那么可以说cA依赖cB。和兌关系不同Q无dcA中定义类Bcd的属性?/p>

聚集QAggregationQ?/strong>
  聚集指的是整体与部分之间的关p,在UML中用带实U的菱Ş头表示?br /> 聚集关系q可以分ZU类型:
  ?nbsp;被聚集的子系l允许被拆卸和替换,q是普通聚集关pR?br />   ?nbsp;被聚集的子系l不允许被拆卸和替换Q这U聚集称为强聚集关系Q或者组成关pR?br />    注:集(l成Q可用带实线的实心菱形箭?/strong>表示?br />    
泛化QGeneralizationQ?/strong>
  泛化指的是类之间的承关p,在UML中用带实U的三角形箭?/strong>表示?br />   
实现QRealizationQ?br />   实现指的是类与接口之间的关系Q在UML中用带虚U的三角形箭?/strong>表示?nbsp;



Ke 2007-10-21 19:36 发表评论
]]>
4U访问别的可访问范?/title><link>http://www.aygfsteel.com/keweibo/articles/150158.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 02 Oct 2007 02:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/150158.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/150158.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/150158.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/150158.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/150158.html</trackback:ping><description><![CDATA[<table style="width: 812px; height: 139px" cellspacing="2" cellpadding="2" width="812" border="0"> <tbody> <tr bgcolor="#c0c0c0"> <td><strong>讉KU别</strong></td> <td><strong>讉K控制修饰W?/strong></td> <td> <p align="center"><strong>?nbsp;   c?/strong></p> </td> <td> <p align="center"><strong>?nbsp;   ?/strong></p> </td> <td> <p align="center"><strong>?nbsp;   c?/strong></p> </td> <td> <p align="center"><strong>不同的包</strong></p> </td> </tr> <tr> <td>公开</td> <td>public </td> <td>√</td> <td>√</td> <td>√</td> <td>√</td> </tr> <tr> <td>受保?/td> <td>protected</td> <td>√</td> <td>√</td> <td>√</td> <td>Q?/td> </tr> <tr> <td>默认</td> <td>没有讉K修饰W?/td> <td>√</td> <td>√</td> <td>Q?/td> <td>Q?/td> </tr> <tr> <td>U有</td> <td>private</td> <td>√</td> <td>Q?/td> <td>Q?/td> <td>Q?/td> </tr> </tbody> </table> <br /> <img src ="http://www.aygfsteel.com/keweibo/aggbug/150158.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2007-10-02 10:13 <a href="http://www.aygfsteel.com/keweibo/articles/150158.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cR方法、成员变量和局部变量的可用修饰W?/title><link>http://www.aygfsteel.com/keweibo/articles/150157.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 02 Oct 2007 02:05:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/150157.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/150157.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/150157.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/150157.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/150157.html</trackback:ping><description><![CDATA[<table style="width: 638px; height: 299px" cellspacing="2" cellpadding="2" width="638" bgcolor="#ffffff" border="0"> <tbody> <tr bgcolor="#c0c0c0"> <td><strong>修饰W?/strong></td> <td><strong>c?/strong></td> <td><strong>成员访求</strong></td> <td><strong>构造方?/strong></td> <td><strong>成员变量</strong></td> <td><strong>局部变?/strong></td> </tr> <tr> <td><span style="color: red">abstract</span>Q抽象的Q?/td> <td>√</td> <td>√</td> <td>Q?/td> <td>Q?/td> <td>Q?/td> </tr> <tr> <td><span style="color: red">static </span>Q静态的Q?/td> <td>Q?/td> <td>√</td> <td>Q?/td> <td>√</td> <td>Q?/td> </tr> <tr> <td><span style="color: red">public</span>Q公qQ?/td> <td style="width: 18px; height: 24px">√</td> <td>√</td> <td>√</td> <td>√</td> <td>Q?/td> </tr> <tr> <td><span style="color: red">protected</span>Q受保护的)</td> <td></td> <td>√</td> <td>√</td> <td>√</td> <td>Q?/td> </tr> <tr> <td><span style="color: red">private</span>Q私有的Q?/td> <td>Q?/td> <td>√</td> <td>√</td> <td>√</td> <td>Q?/td> </tr> <tr> <td><span style="color: red">synchronized</span>Q同步的Q?/td> <td>Q?/td> <td>√</td> <td>Q?/td> <td>Q?/td> <td>Q?/td> </tr> <tr> <td><span style="color: red">native</span>Q本地的Q?/td> <td>Q?/td> <td>√</td> <td>Q?/td> <td>Q?/td> <td>Q?/td> </tr> <tr> <td><span style="color: red">transient</span>Q暂时的Q?/td> <td>Q?/td> <td>Q?/td> <td>Q?/td> <td>√</td> <td>Q?/td> </tr> <tr> <td><span style="color: red">volatie</span>Q易qQ?/td> <td>Q?/td> <td>Q?/td> <td>Q?/td> <td>√</td> <td>Q?/td> </tr> <tr> <td><span style="color: red">final</span>Q不要改变的Q?/td> <td>√</td> <td>√</td> <td>Q?/td> <td>√</td> <td>√</td> </tr> </tbody> </table> <br /> <img src ="http://www.aygfsteel.com/keweibo/aggbug/150157.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2007-10-02 10:05 <a href="http://www.aygfsteel.com/keweibo/articles/150157.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ҏ覆盖与方法重?/title><link>http://www.aygfsteel.com/keweibo/articles/150154.html</link><dc:creator>Ke</dc:creator><author>Ke</author><pubDate>Tue, 02 Oct 2007 01:49:00 GMT</pubDate><guid>http://www.aygfsteel.com/keweibo/articles/150154.html</guid><wfw:comment>http://www.aygfsteel.com/keweibo/comments/150154.html</wfw:comment><comments>http://www.aygfsteel.com/keweibo/articles/150154.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/keweibo/comments/commentRss/150154.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/keweibo/services/trackbacks/150154.html</trackback:ping><description><![CDATA[<span style="color: red">Ҏ重蝲</span>必须满的条Ӟ<br /> <br /> *    Ҏ名相?br /> *    Ҏ的参数类型、个数、顺序至有一不相同<br /> *    Ҏ的返回类型可以不相同<br /> *    Ҏ的修饰符可以不相?br /> <br /> <span style="color: red">Ҏ覆盖</span>必须满多种U束Q?br /> <br /> *    子类Ҏ的名U、参数签名和q回的类型必M父类Ҏ的名U、参数签名和q回cd<br /> 一致?br /> *    子类Ҏ不能~小父类Ҏ的访问权限?br /> *    子类Ҏ不能抛出比父cL法的更多的异常?br /> *    Ҏ覆盖只存在于子类和父cM间?br /> *    父类的静态方法不能被子类覆盖为非静态的Ҏ?br /> *    子类可以定义与父c静态方法同名的静态方法,以便在子cM隐藏父类的静态方法?br /> *    父类的非静态方法不能被子类覆盖为静态方法?br /> *    父类的私有方法不能被子类覆盖?br /> *    父杰的抽象方法可以被子类通过两种途径覆盖Q一是子cd现父cȝ抽象访求Q二是子c重新声明父cȝ抽象Ҏ?br /> *    父类的非抽象Ҏ可以被子c覆盖ؓ抽象Ҏ?br /> <br /> <br /> <br /> <img src ="http://www.aygfsteel.com/keweibo/aggbug/150154.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/keweibo/" target="_blank">Ke</a> 2007-10-02 09:49 <a href="http://www.aygfsteel.com/keweibo/articles/150154.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>l承http://www.aygfsteel.com/keweibo/articles/150152.htmlKeKeTue, 02 Oct 2007 01:37:00 GMThttp://www.aygfsteel.com/keweibo/articles/150152.htmlhttp://www.aygfsteel.com/keweibo/comments/150152.htmlhttp://www.aygfsteel.com/keweibo/articles/150152.html#Feedback0http://www.aygfsteel.com/keweibo/comments/commentRss/150152.htmlhttp://www.aygfsteel.com/keweibo/services/trackbacks/150152.html public class Sub extends Base{
    ... ...
}
以上代码表明Subcȝ承了Basec?那么子类到底l承了父cȝ哪些东西?q还需要分?br /> 以下两种情况:
*    当子cd父类位于同一个包?/span>Q子cȝ承父cMpublic?nbsp; protected    ?/span>default讉KU别的成员变量和成员Ҏ
*    当子cd父类不在同一个包?/span>Q子cȝ承父cMpublic?nbsp; protected    讉KU别的成员变量和成员Ҏ


Ke 2007-10-02 09:37 发表评论
]]>
վ֩ģ壺 | ͨμ| | | ƺ| | Ͽ| ϸ| ֿ| | Դ| | ָɽ| Ʊ| | | Ӫ| Ԫ| | ɽ| ˰| ͨ| ̨| | ȫ| | | ־| ڰ| | | | | | | | | | ԫ| | ľ|