亚洲中文字幕无码爆乳app,亚洲综合精品一二三区在线,亚洲精品无码乱码成人http://www.tkk7.com/zhyiwww/category/8510.html用平實的筆,記錄編程路上的點點滴滴………zh-cnThu, 07 Apr 2011 08:51:27 GMTThu, 07 Apr 2011 08:51:27 GMT60eclipse上顯示代碼打印邊線http://www.tkk7.com/zhyiwww/archive/2011/04/07/347805.htmlzhyiwwwzhyiwwwThu, 07 Apr 2011 08:30:00 GMThttp://www.tkk7.com/zhyiwww/archive/2011/04/07/347805.htmlhttp://www.tkk7.com/zhyiwww/comments/347805.htmlhttp://www.tkk7.com/zhyiwww/archive/2011/04/07/347805.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/347805.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/347805.html


zhyiwww 2011-04-07 16:30 發表評論
]]>
java中什么時候使用finalize()方法http://www.tkk7.com/zhyiwww/archive/2010/11/26/339105.htmlzhyiwwwzhyiwwwFri, 26 Nov 2010 02:12:00 GMThttp://www.tkk7.com/zhyiwww/archive/2010/11/26/339105.htmlhttp://www.tkk7.com/zhyiwww/comments/339105.htmlhttp://www.tkk7.com/zhyiwww/archive/2010/11/26/339105.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/339105.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/339105.html 這一點給了我們發開發人員省了不少心,但是finalize()方法一直是個困惑。
虛擬機在執行垃圾回收之前都會執行對象的finalize(),那么finalize()到底有什么用呢?
其實finalize()主要是給其他調用而創建的空間在對象回收時頁同步回收而設置的。
比如,你調用了C語言,使用了mallow()開辟了一段內存空間。在你釋放java對象的時候,虛擬機只能釋放java對象占用的空間,而不能釋放C開辟的內存空間,所你你在釋放此對象之前要先回收你在C語言中開辟的空間。
這各時候才用到finalize()方法。
平時的時候不要隨便使用finalize()方法。

以上理解是《java編程思想中的理論》,詳細深入的理解請參考此書 。




zhyiwww 2010-11-26 10:12 發表評論
]]>
在linux上安裝JDKhttp://www.tkk7.com/zhyiwww/archive/2009/06/24/283938.htmlzhyiwwwzhyiwwwWed, 24 Jun 2009 06:53:00 GMThttp://www.tkk7.com/zhyiwww/archive/2009/06/24/283938.htmlhttp://www.tkk7.com/zhyiwww/comments/283938.htmlhttp://www.tkk7.com/zhyiwww/archive/2009/06/24/283938.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/283938.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/283938.htmljdk-6u14-linux-x64.bin

[2]添加執行權限
chmod a+x jdk-6u14-linux-x64.bin

[3]執行安裝
./jdk-6u14-linux-x64.bin
默認的安裝路徑是/usr/java/jdk-1.6.0_14

[4]最關鍵的一步,配置環境變量
vim /etc/profile
添加如下內容:
設置PATH

PATH=$PATH:/usr/java/jdk-1.6.0_14/bin
export PATH

設置JAVA_HOME
export JAVA_HOME=/usr/java/jdk-1.6.0_14

[5]讓你的設置生效
source /etc/profile

[6]檢查你的設置效果
[XXX java]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/zhangyi/bin:/usr/java/jdk1.6.0_14/bin
[XXX java]$

[XXX java]$ echo $JAVA_HOME
/usr/java/jdk1.6.0_14
[XXX java]$

[XXX java]$ java
Usage: java [-options] class [args...]
?????????? (to execute a class)
?? or? java [-options] -jar jarfile [args...]
?????????? (to execute a jar file)

where options include:
??? -d32????????? use a 32-bit data model if available

??? -d64????????? use a 64-bit data model if available
??? -server??? ? to select the "server" VM
????????????????? The default VM is server.
?????????????????
??? -cp <class search path of directories and zip/jar files>
。。。。。。。。。。。。


[XXX java]$ javac
用法:javac <選項> <源文件>
其中,可能的選項包括:
? -g???????????????????????? 生成所有調試信息
? -g:none??????????????????? 不生成任何調試信息
? -g:{lines,vars,source}???? 只生成某些調試信息
? -nowarn??????????????????? 不生成任何警告
? -verbose?????????????????? 輸出有關編譯器正在執行的操作的消息
? -deprecation?????????????? 輸出使用已過時的 API 的源位置
? -classpath <路徑>??????????? 指定查找用戶類文件和注釋處理程序的位置
? -cp <路徑>?????????????????? 指定查找用戶類文件和注釋處理程序的位置
? -sourcepath <路徑>?????????? 指定查找輸入源文件的位置
? -bootclasspath <路徑>??????? 覆蓋引導類文件的位置
? -extdirs <目錄>????????????? 覆蓋安裝的擴展目錄的位置
。。。。。。。。。。。。。。。。

如果你能看到上面的額內容,那么你的JDK就安裝和配置成功了。









zhyiwww 2009-06-24 14:53 發表評論
]]>
如何取得ResultSet的行數http://www.tkk7.com/zhyiwww/archive/2009/06/19/283265.htmlzhyiwwwzhyiwwwFri, 19 Jun 2009 09:25:00 GMThttp://www.tkk7.com/zhyiwww/archive/2009/06/19/283265.htmlhttp://www.tkk7.com/zhyiwww/comments/283265.htmlhttp://www.tkk7.com/zhyiwww/archive/2009/06/19/283265.html#Feedback2http://www.tkk7.com/zhyiwww/comments/commentRss/283265.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/283265.html在ResultSet對象里面,我們找不到取得結果行數的辦法。
其實我們通常的解決方法無非有一下幾種:

[1]
Connection con=....
Statement stmt = con.createStatement();
? ?
?String sqlStr = "count(*) as total ";
?ResultSet rst = stmt.executeQuery(sqlStr);
?
?rst.next();
int total =? rst.getInt("total");

缺點:如果想要遍歷結果集,你不得不在執行一次查詢,取得結果集。

[2]

?? ??? ??? ?String accQrySql = "select * from accounts";
?? ??? ??? ?Connection con = DBUtils.getConnection();
?? ??? ??? ?Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
?? ??? ??? ?
?? ???????????????? ResultSet rst = stmt.executeQuery(accQrySql);

?????????????????????? 你可以通過下面的方法來取得結果集的記錄數目
?????????????????????? rst.last();
?????????????????????? int total = rst.getRow();

?????????????????????? 這時,你可以取得記錄數目。

?????????????????????? 如果
while(rst.next()){
........
}???? ?

int total = rst.getRow();
你將得到的total是0

因為,getRow是在遍歷結果集的時候的指針,也是在結果集內移動的指針,也就是說,指向了當前的記錄索引號,所以,在進行結果集的遍歷前和后都被重置成0。
所以,想取得記錄的條數,可以把指針移到最后一條記錄,然后取得當前記錄的編號就是記錄的條數。
所以,必須用
rst.last();
之后才能用 rst.getRow()來取得,才能取到值。

注意:想要用這種方法來取得結果集的行數,必須用 可滾動結果集???? ?
?? ?Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
否則,你就不能執行
rst.last()
也就不能取得結果集的條數。



zhyiwww 2009-06-19 17:25 發表評論
]]>
hibernate多對多刪除和更新中間表http://www.tkk7.com/zhyiwww/archive/2009/02/16/254872.htmlzhyiwwwzhyiwwwMon, 16 Feb 2009 05:14:00 GMThttp://www.tkk7.com/zhyiwww/archive/2009/02/16/254872.htmlhttp://www.tkk7.com/zhyiwww/comments/254872.htmlhttp://www.tkk7.com/zhyiwww/archive/2009/02/16/254872.html#Feedback7http://www.tkk7.com/zhyiwww/comments/commentRss/254872.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/254872.html這幾天,在多隊多的中間表的操作上遇到了點麻煩,總是不能刪除和更新中間表,因為,我使用的是一隊多的關聯,
映射的是中間表,所以,我雖然操作了set,但是總是不能反映到中間表上去。

后來使用如下的方法來解決,看如下的例子:

(1)三個表

CREATE TABLE `poi` (
? `poi_id` INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
? `poi_name` VARCHAR(45) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
? PRIMARY KEY (`poi_id`),
? UNIQUE KEY `poi_name` (`poi_name`)

)ENGINE=InnoDB
AUTO_INCREMENT=15 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci'
COMMENT='InnoDB free: 3072 kB';


CREATE TABLE `user` (
? `user_id` INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
? `username` VARCHAR(45) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
? `password` VARCHAR(45) COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
? PRIMARY KEY (`user_id`),
? UNIQUE KEY `username` (`username`)

)ENGINE=InnoDB
AUTO_INCREMENT=16 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci'
COMMENT='InnoDB free: 3072 kB';


關聯表

CREATE TABLE `user_poi` (
? `user_id` INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
? `poi_id` INTEGER(10) UNSIGNED NOT NULL,
? KEY `FK_user_pois_poiid` (`poi_id`),
? KEY `FK_user_pois_userid` (`user_id`),
? CONSTRAINT `FK_user_pois_poiid` FOREIGN KEY (`poi_id`) REFERENCES `poi` (`poi_id`) ON DELETE CASCADE ON UPDATE CASCADE,
? CONSTRAINT `FK_user_pois_userid` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE

)ENGINE=InnoDB
AUTO_INCREMENT=3 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci'
COMMENT='InnoDB free: 3072 kB; (`poi_id`) REFER `demo/poi`(`poi_id`) ON UPDATE CASCADE; (';


(2)POJO


/**
?* @hibernate.class table="user"
?*/
public class User implements java.io.Serializable {

??? // Fields

??? private Integer userid;
??? private String username;
??? private String password;

??? /**
??? ?* Poi set
??? ?*/
??? private Set<Poi> pois = new HashSet();
???
???
???
??? // Constructors

??? /**
??? ?* @hibernate.set table="user_poi" cascade="all"
??? ?* @hibernate.collection-key column="user_id"
??? ?* @hibernate.collection-many-to-many column="poi_id" class="org.zy.pro.pd.dao.Poi"
??? ?*/
??? public Set getPois() {
??? ??? return pois;
??? }

??? public void setPois(Set pois) {
??? ??? this.pois = pois;
??? }

??? public User() {
??? }

??? /** full constructor */
??? public User(String username, String password) {
??? ??? this.username = username;
??? ??? this.password = password;
??? }

??? // Property accessors


??? /**
??? ?* @hibernate.id column="user_id" generator-class="increment"
??? ?*/
??? public Integer getUserid() {
??? ??? return this.userid;
??? }

??? public void setUserid(Integer userid) {
??? ??? this.userid = userid;
??? }

??? /**
??? ?* @hibernate.property column="username"
??? ?* @return
??? ?*/
??? public String getUsername() {
??? ??? return this.username;
??? }

??? public void setUsername(String username) {
??? ??? this.username = username;
??? }

??? /**
??? ?* @hibernate.property column="password"
??? ?* @return
??? ?*/
??? public String getPassword() {
??? ??? return this.password;
??? }

??? public void setPassword(String password) {
??? ??? this.password = password;
??? }

}


/**
?* @hibernate.class table="poi"
?*/
public class Poi? implements java.io.Serializable {


??? // Fields???

???? private Integer poiId;
???? private String poiName;


??? // Constructors

??? /** default constructor */
??? public Poi() {
??? }

??? /** minimal constructor */
??? public Poi(String poiName) {
??????? this.poiName = poiName;
??? }


??? /**
???? * @hibernate.id column="poi_id" generator-class="increment"
???? */
??? public Integer getPoiId() {
??????? return this.poiId;
??? }
???
??? public void setPoiId(Integer poiId) {
??????? this.poiId = poiId;
??? }

??? /**
???? * @hibernate.property column="poi_name"
???? * @return
???? */
??? public String getPoiName() {
??????? return this.poiName;
??? }
???
??? public void setPoiName(String poiName) {
??????? this.poiName = poiName;
??? }
}



(3)hibernate mapping

利用xDolect根據bean生成映射

Poi.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
??? "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
??? "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
??? <class
??????? name="org.zy.pro.pd.dao.Poi"
??????? table="poi"
??? >

??????? <id
??????????? name="poiId"
??????????? column="poi_id"
??????????? type="java.lang.Integer"
??????? >
??????????? <generator class="increment">
????
??????????? </generator>
??????? </id>

??????? <property
??????????? name="poiName"
??????????? type="java.lang.String"
??????????? update="true"
??????????? insert="true"
??????????? column="poi_name"
??????? />

??? </class>

</hibernate-mapping>


User.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
??? "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
??? "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
??? <class
??????? name="org.zy.pro.pd.dao.User"
??????? table="user"
??? >

??????? <id
??????????? name="userid"
??????????? column="user_id"
??????????? type="java.lang.Integer"
??????? >
??????????? <generator class="increment">

??????????? </generator>
??????? </id>

??????? <set
??????????? name="pois"
??????????? table="user_poi"
??????????? lazy="false"
??????????? cascade="all"
??????????? sort="unsorted"
??????? >

??????????? <key
??????????????? column="user_id"
??????????? >
??????????? </key>

??????????? <many-to-many
??????????????? class="org.zy.pro.pd.dao.Poi"
??????????????? column="poi_id"
??????????????? outer-join="auto"
???????????? />

??????? </set>

??????? <property
??????????? name="username"
??????????? type="java.lang.String"
??????????? update="true"
??????????? insert="true"
??????????? column="username"
??????? />

??????? <property
??????????? name="password"
??????????? type="java.lang.String"
??????????? update="true"
??????????? insert="true"
??????????? column="password"
??????? />



??? </class>

</hibernate-mapping>


(4)關聯添加
??????? UserDAO ud = new UserDAO();
??? ??? List l = ud.findAll();
??? ??? assertNotNull(l);
??? ???
??? ??? User u = ud.findById(2);
??? ??? assertNotNull(u);
??? ???
??? ??? Set pois = u.getPois();
??? ???
??? ??? Poi p = new Poi("Moc"+new java.util.Random().nextInt(1000000));
??? ??? System.out.print(p.getPoiId());
??? ???
??? ???
??? ??? pois.add(p);

//關聯刪除
//??? ??? u.setPois(null);
??? ???
??? ??? Poi pp = pd.findById(12);
??? ??? pois.remove(pp);
??? ???
??? ???
??? ??? ud.begin();
??? ??? ud.merge(u);
??? ??? ud.commit();


// 關聯更新也可以,只要改變set就可以了。



使用總結
[1]使用多對多關系
??? 在映射的是時候要使用many-to-many
??? 所以,在user的set集合里面直接存放的是Poi的對象,而不是user_poi表的對象
[2]reverse : false
??? 允許反轉操作
[3]casecade : all
??? 只要允許級聯操作才可以實現級聯的刪除和更新

如果使用一對多,就只能更新中間表的普通字段,不能更新主鍵字段,也不能刪除中間表記錄
所以只能維護中間表的關聯,但是不能更新中間表的信息。





zhyiwww 2009-02-16 13:14 發表評論
]]>
ant運行java不能輸出log4j日志問題的解決http://www.tkk7.com/zhyiwww/archive/2008/12/19/247297.htmlzhyiwwwzhyiwwwFri, 19 Dec 2008 03:41:00 GMThttp://www.tkk7.com/zhyiwww/archive/2008/12/19/247297.htmlhttp://www.tkk7.com/zhyiwww/comments/247297.htmlhttp://www.tkk7.com/zhyiwww/archive/2008/12/19/247297.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/247297.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/247297.html 程序在eclipse下運行,日志輸出正常。我的build.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="USSD" basedir="." default="compile">
??? <property name="src.dir" value="src"/>
??? <property name="build.dir" value="bin"/>
??? <property name="lib.dir" value="F:\OPEN-LIB"/>
??? <path id="compile.lib">
??? ??? <fileset dir="${lib.dir}">
??? ??? ??? <include name="ojdbc14.jar"/>??? ??? ???
??? ??? ??? <include name="log4j-1.2.12.jar"/>
??? ??? ??? <include name="commons-dbcp-1.2.2.jar"/>
??? ??? ??? <include name="commons-pool-1.3.jar"/>???
??? ??? </fileset>
??? ??? <pathelement path="${build.dir}"/>???
??? </path>
??? <target name="initdir">
??? ???
??? </target>
??? <target name="compile">
??? ??? <javac srcdir="${src.dir}" destdir="${build.dir}">
??? ??? ??? <classpath refid="compile.lib"/>
??? ??? </javac>
??? </target>
??? <target name="run" depends="compile">
??? ??? <java dir="${build.dir}" classname="com.cybersoftchina.ussd.PushMain">
??? ??? ??? <classpath refid="compile.lib"/>
??? ??? </java>
??? </target>
</project>

我的第一次分析,就覺得可能是,ant系統在運行的時候沒有找到配置文件log4j.properties.
所以,我就把src\log4j.properties 復制到 工程的根目錄,然后再運行,發現還是不行。

所以,我就想到是src下的配置文件,在編譯之后應該復制到了和classes目錄下相對應的路徑。
所以,我就到bin目錄下找,果然沒有。
因為我在build.xml文件中,compile的時候,并沒有把配置文件log4j.properties復制到其對應目錄。
所以,復制src\log4j.properties到bin\log4j.properties。
再運行,OK了。

解決方案:
把src目錄的所有配置文件(此處是log4j.properties配置文件)復制到classes目錄的對應目錄。

修改build.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="USSD" basedir="." default="compile">
??? <property name="src.dir" value="src"/>
??? <property name="build.dir" value="bin"/>
??? <property name="lib.dir" value="F:\OPEN-LIB"/>
??? <path id="compile.lib">
??? ??? <fileset dir="${lib.dir}">
??? ??? ??? <include name="ojdbc14.jar"/>??? ??? ???
??? ??? ??? <include name="log4j-1.2.12.jar"/>
??? ??? ??? <include name="commons-dbcp-1.2.2.jar"/>
??? ??? ??? <include name="commons-pool-1.3.jar"/>???
??? ??? </fileset>
??? ??? <pathelement path="${build.dir}"/>???
??? </path>
??? <target name="initdir">
??? ???
??? </target>
??? <target name="compile">
??? ??? <javac srcdir="${src.dir}" destdir="${build.dir}">
??? ??? ??? <classpath refid="compile.lib"/>
??? ??? </javac>
??? </target>
??? <target name="run" depends="compile">
??? ??? <java dir="${build.dir}" classname="com.cybersoftchina.ussd.PushMain">
??? ??? ??? <classpath refid="compile.lib"/>
??? ??? </java>
??? </target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="USSD" basedir="." default="compile">
??? <property name="src.dir" value="src"/>
??? <property name="build.dir" value="bin"/>
??? <property name="lib.dir" value="F:\OPEN-LIB"/>
??? <path id="compile.lib">
??? ??? <fileset dir="${lib.dir}">
??? ??? ??? <include name="ojdbc14.jar"/>??? ??? ???
??? ??? ??? <include name="log4j-1.2.12.jar"/>
??? ??? ??? <include name="commons-dbcp-1.2.2.jar"/>
??? ??? ??? <include name="commons-pool-1.3.jar"/>???
??? ??? </fileset>
??? ??? <pathelement path="${build.dir}"/>???
??? </path>
??? <target name="initdir">
??? ???
??? </target>
??? <target name="compile">
??? ??? <javac srcdir="${src.dir}" destdir="${build.dir}">
??? ??? ??? <classpath refid="compile.lib"/>
??? ??? </javac>
??? ??? <copy todir="${build.dir}">
??? ??? ??? <fileset dir="${src.dir}">
??? ??? ??? ??? <include name="**/*.properties"/>???
??? ??? ??? ??? <include name="**/*.xml"/>
??? ??? ??? </fileset>
??? ??? </copy>

??? </target>
??? <target name="run" depends="compile">
??? ??? <java dir="${build.dir}" classname="com.cybersoftchina.ussd.PushMain">
??? ??? ??? <classpath refid="compile.lib"/>
??? ??? </java>
??? </target>
</project>

上面的深藍色的部分是新添加的部分。這樣,在編譯的時候就把所有的配置文件也一同復制到了class文件夾下面了。

再ant run ,就在文件中有日志了。









zhyiwww 2008-12-19 11:41 發表評論
]]>
我自己寫的一個Ant通用模板build.xmlhttp://www.tkk7.com/zhyiwww/archive/2008/10/28/237200.htmlzhyiwwwzhyiwwwTue, 28 Oct 2008 12:12:00 GMThttp://www.tkk7.com/zhyiwww/archive/2008/10/28/237200.htmlhttp://www.tkk7.com/zhyiwww/comments/237200.htmlhttp://www.tkk7.com/zhyiwww/archive/2008/10/28/237200.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/237200.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/237200.html<?xml version="1.0" encoding="UTF-8"?>
<project name="Push_Demo" basedir="." default="">
?
?<!-- project properties -->
?? ?<property name="pro.name" value="push" />
?? ?<property name="pro.dir" value="." />

?<!-- tomcat properties -->
?? ?<property name="tomcat.home" value="/green/apache-tomcat-6.0.14" />
?? ?<property name="tomcat.lib" value="${tomcat.home}/lib" />
?

?<!-- dirctionary properties -->
?? ?<property name="src.dir" value="src" />
?? ?<property name="web.dir" value="WebRoot" />
?? ?<property name="lib.dir" value="${web.dir}\WEB-INF\lib" />
?? ?<property name="classes.dir" value="${web.dir}\WEB-INF\classes" />
?? ?<property name="deploy.dir" value="${tomcat.home}\webapps\${pro.name}" />
?
?<!-- lib properties? -->
?? ?<path id="compile.lib">
?? ??? ?<fileset dir="${lib.dir}">
?? ??? ??? ?<include name="*.jar" />
?? ??? ?</fileset>
?? ??? ?<fileset dir="${tomcat.lib}">
?? ??? ??? ?<include name="*.jar" />
?? ??? ?</fileset>
?? ?</path>
?
?<!-- -->
?? ?<target name="compile.mkdir">
?? ??? ?<mkdir dir="${classes.dir}" />
?? ?</target>
?
?<!-- -->
?? ?<target name="compile.rmdir">
?? ??? ?<delete dir="${classes.dir}" />
?? ?</target>
?<!-- initialize deploy directory -->
?? ?<target name="deploy.init">
?? ??? ?<delete dir="${deploy.dir}" />
?? ??? ?<mkdir dir="${deploy.dir}" />
?? ?</target>
?
?<!-- compile java source files -->
?? ?<target name="compile">
?? ??? ?<echo>compiling the java code</echo>
?? ??? ?<javac srcdir="${src.dir}" destdir="${classes.dir}" encoding="UTF-8"
?? ??? ??? ?debug="on">
?? ??? ??? ?<classpath refid="compile.lib" />
?? ??? ?</javac>
?? ?</target>
?? ?<target name="build.copy" depends="compile">
?? ??? ?<copy todir="${classes.dir}">
?? ??? ??? ?<fileset dir="${src.dir}">
?? ??? ??? ??? ?<include name="**/*.properties" />
?? ??? ??? ??? ?<include name="**/*.xml" />
?? ??? ??? ?</fileset>
?? ??? ?</copy>
?? ?</target>
?? ?<target name="deploy.copy">
?? ??? ?<copy todir="${deploy.dir}">
?? ??? ??? ?<fileset dir="${web.dir}">
?? ??? ??? ??? ?<include name="**/*.*"/>
?? ??? ??? ?</fileset>
?? ??? ?</copy>
?? ?</target>
?? ?
?? ?<target name="build" depends="compile,build.copy" />
?? ?<target name="rebuild" depends="compile.rmdir,compile.mkdir,build" />
?? ?
?? ?<target name="deploy" depends="build,deploy.copy" />
?? ?<target name="redeploy"?? ?depends="deploy.init,deploy" />
?? ?
</project>

zhyiwww 2008-10-28 20:12 發表評論
]]>
Mysql+Hibernate+JSP中文亂碼問題的解決http://www.tkk7.com/zhyiwww/archive/2008/09/09/227986.htmlzhyiwwwzhyiwwwTue, 09 Sep 2008 08:40:00 GMThttp://www.tkk7.com/zhyiwww/archive/2008/09/09/227986.htmlhttp://www.tkk7.com/zhyiwww/comments/227986.htmlhttp://www.tkk7.com/zhyiwww/archive/2008/09/09/227986.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/227986.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/227986.html
1:檢查mysql安裝目錄下的配置文件my.ini,

[mysql]
默認的default-character-set=latin1
改為default-character-set=utf8(不是utf-8)

(注意,如果需要導數據,請先修改完編碼,再進行數據導入,同時,注意你的源數據的格式,需要是utf8的編碼)

2:檢查你的連接:
jdbc:mysql://localhost:3306/mydb?useUnicode=true&amp;characterEncoding=utf8(不是utf-8)
連接數據庫的編碼也要設置為utf8

3: 檢查你的頁面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
設置文件的編碼

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
設置內容編碼

如果這幾個地方都統一了,應該就沒有什么問題了。

中文檢索的實現:
在保證上面編碼問題正確的情況下進行。

首先,如果jsp頁面到action,需要進行編碼的轉換
因為,jsp的頁面form提交到action時,默認的是iso-8859-1的編碼,需要轉換成utf-8編碼
代碼如下:
String keyStr = request.getParameter("key");
??? ???
??? ??? String pageStr = request.getParameter("page");
??? ??? String pageSizeStr = request.getParameter("pageSize");
??? ???
??? ???
??? ??? String key="";
??? ??? try {
??? ??? ??? key = (keyStr==null?"":new String(keyStr.getBytes("iso-8859-1"),"utf-8"));
??? ??? } catch (UnsupportedEncodingException e2) {
??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? e2.printStackTrace();
??? ??? }
??? ???
這樣,能保證,在jsp到action的編碼不會出現亂碼。
然后,在dao端,通過HQL進行中文模糊匹配檢索,代碼如下:
??? public List findLikeKey(String key) {
??? ??? log.debug("finding all Pois instances");
??? ??? try {
??? ??? ??? //'%"+key+"%'
??? ??? ??? String queryString = "from Pois as poi where poi.poiname like '%"+key+"%'";
??? ??? ??? Query queryObject = getSession().createQuery(queryString);
??? ??? ???
//??? ??? ??? queryObject.setString(0, "'%"+key+"'");
??? ??? ???
??? ??? ??? log.info("query String is : "+queryObject.getQueryString());
??? ??? ???
??? ??? ??? return queryObject.list();
??? ??? } catch (RuntimeException re) {
??? ??? ??? log.error("find all failed", re);
??? ??? ??? throw re;
??? ??? }
??? }

這樣就可以實現檢索的模糊匹配。
這樣就OK了。






zhyiwww 2008-09-09 16:40 發表評論
]]>
String和StringBuffer的區別http://www.tkk7.com/zhyiwww/archive/2008/04/25/195993.htmlzhyiwwwzhyiwwwFri, 25 Apr 2008 07:37:00 GMThttp://www.tkk7.com/zhyiwww/archive/2008/04/25/195993.htmlhttp://www.tkk7.com/zhyiwww/comments/195993.htmlhttp://www.tkk7.com/zhyiwww/archive/2008/04/25/195993.html#Feedback1http://www.tkk7.com/zhyiwww/comments/commentRss/195993.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/195993.html從對象實現上來說,都是通過char[]來實現的。
如果new String(),那么數組的長度為0,如果new String("String"),那么char[]數組的長度就是你創建的字符串的長度。
這個char[]在字符串創建以后是不會改變的。
如果你只對這個串本身進行查找等對字符串無改變的操作的話,對于此數組本身是沒有影響的。但是如果,你要執行的是一個對此字符串本身有改變的操作的話,那么,是不可以的。
但是Strin對象為我們提供了此類操作的方法,比如concat()方法,源代碼如下:
??? public String concat(String s) {
??? ??? int i = s.length();
??? ??? if (i == 0) {
??? ??? ??? return this;
??? ??? } else {
??? ??? ??? char ac[] = new char[count + i];
??? ??? ??? getChars(0, count, ac, 0);
??? ??? ??? s.getChars(0, i, ac, count);
??? ??? ??? return new String(0, count + i, ac);
??? ??? }
??? }
由此,我們可以知道,其實,此方法給我們返回的已經不是當前的字符串了,而是又創建了一個新的字符串,然后返回。
其他的方法也類似。

StringBuffer的實現,也是通過char[]來實現的。但是,默認的情況下,其自己創建了一個緩存數組,長度是16,這一點,我們可以通過StringBuffer的構造器來知道:
??? public StringBuffer() {
??? super(16);
??? }
這個方法初始化了,char[]數組的長度是16。
其父類構造器如下:
??? AbstractStringBuilder(int capacity) {
??????? value = new char[capacity];
??? }
也就是說,默認的數組長度是16。
很多的時候,容量16對于我們需要的串來說,可能遠遠不夠。怎么辦呢?
在進行串的append的時候,StringBuffer會檢測剩余容量,并會重新擴充至當前容量的2倍。
??? public AbstractStringBuilder append(String str) {
??? if (str == null) str = "null";
??????? int len = str.length();
??? if (len == 0) return this;
??? int newCount = count + len;
??? if (newCount > value.length)
??? ??? expandCapacity(newCount);
??? str.getChars(0, len, value, count);
??? count = newCount;
??? return this;
??? }

而擴容的同時,會創建一個新的數組,并將原來的數組內容復制到新的數組里面。
由此可見,如果容量不足的話,那么每一次擴容,都會耗掉大量的資源,盡管,你可能擴充的容量也很小。如果,數組的長度很大,耗掉的資源就會更多。
所以,我們在使用stringbuffer的時候,要一次在創建對象的時候給與足夠多的空間,這樣會提高性能。
有利必有弊,這個性能是以空間為代價。但是相對于性能的喪失來說,應該還是值得的。

如果不需要擴容的話,那么所有的操作都是基于同一個數組,那么像對于string的操作來說,不需要每一次都創建對象了,省去了創建對象的時間,性能是要好很多的,同時,String的串操作,會用去很多的空間,對于虛擬機來說,也增加了很大的壓力。





zhyiwww 2008-04-25 15:37 發表評論
]]>
對hashCode的一點簡單認識http://www.tkk7.com/zhyiwww/archive/2008/04/22/194845.htmlzhyiwwwzhyiwwwTue, 22 Apr 2008 10:03:00 GMThttp://www.tkk7.com/zhyiwww/archive/2008/04/22/194845.htmlhttp://www.tkk7.com/zhyiwww/comments/194845.htmlhttp://www.tkk7.com/zhyiwww/archive/2008/04/22/194845.html#Feedback1http://www.tkk7.com/zhyiwww/comments/commentRss/194845.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/194845.htmljava給我們提供了兩種判斷對象對等的方式。如果我們判斷兩個對象是否相等,那么直接用“==”運算就可以了。然而,判斷兩個對象對等,就沒有那么簡單了。
在java中,我們常常通過equals()方法來判斷兩個對象的對等。其實,我么還可以通過hashCode()來判斷兩個對象的對等。

看下面的例子:

import java.util.List;

public class MyBag{
??? float money;
??? List books;??
}
我們如何判斷兩個MyBag對象是對等的呢?也就是說,如果有兩個MyBag的對象bag1和bag2,通過什么的辦法能說明這個兩個對象是相同的呢?
先聲名兩個概念:
兩個對象相等,指的是,兩個引用指向了同一個對象,也就是說,指向了內存中的同一個地址。
兩個對象相同(對等),指得是兩個對象的任何屬性都相等,但是,不是一個對象。

所以,對于上面的MyBag的對象對等,那么,兩個對象的money要一樣,同時,books要對等。那么如何去判斷呢?我們通常會自己去實現equals()方法去判斷,方法如下:

??? public boolean equals(Object obj) {
??? ??? if (this == obj)
??? ??? ??? return true;
??? ??? if (obj == null)
??? ??? ??? return false;
??? ??? if (getClass() != obj.getClass())
??? ??? ??? return false;
??? ??? final MyBag other = (MyBag) obj;
??? ??? if (books == null) {
??? ??? ??? if (other.books != null)
??? ??? ??? ??? return false;
??? ??? } else if (!books.equals(other.books))
??? ??? ??? return false;
??? ??? if (Float.floatToIntBits(money) != Float.floatToIntBits(other.money))
??? ??? ??? return false;
??? ??? return true;
??? }

我們也可以通過實現hashCode()來實現:
??? public int hashCode() {
??? ??? final int prime = 31;
??? ??? int result = 1;
??? ??? result = prime * result + ((books == null) ? 0 : books.hashCode());
??? ??? result = prime * result + Float.floatToIntBits(money);
??? ??? return result;
??? }

那么我們判斷兩個對象對等時,就可以這樣來實現了:
if(bag1.equals(bag2)){
??? // 對等
}

或者
if(bag1.haseCode()==bag2.hashCode()){
??? // 對等
}

為什么這種方式也能判斷兩個對象對等呢?
因為,任何一個對象的hashCode是唯一的,并且和氣對象屬性按照一定的規則相關的。

比如,一個Integer的hashCode值就是其整數值,因為Integer的haseCode()是這樣實現的:
??? public int hashCode() {
??? ??? return value;
??? }
??? public boolean equals(Object obj) {
??? ??? if (obj instanceof Integer)
??? ??? ??? return value == ((Integer) obj).intValue();
??? ??? else
??? ??? ??? return false;
??? }

由此可以看到,也對象的HashCode是和其屬性有一定的聯系,規則和屬性的值有一定的聯系,這個規則決定了有相同的hashcode,就有兩個對象的屬性對等。



zhyiwww 2008-04-22 18:03 發表評論
]]>
從類的改造小談內部類http://www.tkk7.com/zhyiwww/archive/2007/10/25/155806.htmlzhyiwwwzhyiwwwThu, 25 Oct 2007 03:19:00 GMThttp://www.tkk7.com/zhyiwww/archive/2007/10/25/155806.htmlhttp://www.tkk7.com/zhyiwww/comments/155806.htmlhttp://www.tkk7.com/zhyiwww/archive/2007/10/25/155806.html#Feedback1http://www.tkk7.com/zhyiwww/comments/commentRss/155806.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/155806.htmlhttp://www.tkk7.com/raylong1982/archive/2007/10/24/155439.html
中關于內部類的介紹和分析的時候,就想到了我剛寫的那個回答面試問題的簡單代碼,是不是也可以改用內部類來實現呢?
所以就做了一個簡單的改進,代碼如下:
package org.zy.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ParseUrlUsingInnerClass {
???
???
???
??? public static void main(String[] args){
??? ??? Timer t = new Timer();
??? ??? t.schedule(new ParseTask(),0,5*60*60);??? ??? ???
??? }
???
???
??? class ParseTask extends TimerTask{

??? ??? public void run(){
??? ??? ??? System.out.println("runing");
??? ??? ??? try {
??? ??? ??? ??? // create url object
??? ??? ??? ??? URL url = new URL("http://post.baidu.com/f?kw=%D2%EC%C8%CB%B0%C1%CA%C0%C2%BC");
??? ??? ??? ??? // get the input stream reader from the url
??? ??? ??? ??? InputStreamReader isr = new InputStreamReader(url.openStream());
??? ??? ??? ??? // buffered the reader
??? ??? ??? ??? BufferedReader br = new BufferedReader(isr);
??? ??? ??? ???
??? ??? ??? ??? // store the temp string
??? ??? ??? ??? StringBuffer sb = new StringBuffer(10000);
??? ??? ??? ??? // temporary variable for each read
??? ??? ??? ??? String tmp="";
??? ??? ??? ???
??? ??? ??? ??? // read the content from reader
??? ??? ??? ??? while((tmp=br.readLine())!=null){
??? ??? ??? ??? ??? sb.append(tmp);
??? ??? ??? ??? }
??? ??? ??? ??? System.out.println(sb.toString());
??? ??? ??? ??? // match from the orginal string using? reglex express
??? ??? ??? ??? Pattern p = Pattern.compile("<<.*異人.*>>");
??? ??? ??? ??? Matcher m = p.matcher(sb.toString());??? ??? ??? ???
??? ??? ??? ???
??? ??? ??? ???
??? ??? ??? } catch (MalformedURLException e) {
??? ??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? ??? e.printStackTrace();
??? ??? ??? } catch (IOException e) {
??? ??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? ??? e.printStackTrace();
??? ??? ??? }
??? ??? }
??? }
}

看藍色代碼部分,很顯然,我直接作了一個最簡單的修改,就是直接把外面定義的拿給類拿到了public類的里面,其他的代碼都沒有改變。
但是代碼卻出現了問題。
??? public static void main(String[] args){
??? ??? Timer t = new Timer();
??? ??? t.schedule(new ParseTask(),0,5*60*60);??? ??? ???
??? }
上面的這段代碼就出現了問題,為什么呢?
我們知道,一個static的方法,只能使用static屬性和方法和static類,那么
new ParseTask()能行嗎?
問題就出在這,此處不能創建一個非靜態類的對象。
所以,我們就只能在類的定義前面添加一個static,讓其成為一個靜態類就可以了。
修改后的代碼如下:
static class ParseTask extends TimerTask{
一般情況下,我們不創建static類,這個地方是因為我們在static main 方法里面直接使用,所以就只能創建靜態類。
我們的代碼還可以改變:
可以把調用部分封裝成一個方法,然后在此方法里面調用內部類,就可以不用定義靜態類了,代碼如下:

package org.zy.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ParseUrlUsingInnerClass1 {
???
??? public void parseUrl(){
??? ??? Timer t = new Timer();
??? ??? t.schedule(new ParseTask(),0,5*60*60);??? ???
??? }
???
??? public static void main(String[] args){
??? ??? ParseUrlUsingInnerClass1 puic = new ParseUrlUsingInnerClass1();
??? ??? puic.parseUrl();
??? }
???
???
??? class ParseTask extends TimerTask{

??? ??? public void run(){
??? ??? ??? System.out.println("runing");
??? ??? ??? try {
??? ??? ??? ??? // create url object
??? ??? ??? ??? URL url = new URL("http://post.baidu.com/f?kw=%D2%EC%C8%CB%B0%C1%CA%C0%C2%BC");
??? ??? ??? ??? // get the input stream reader from the url
??? ??? ??? ??? InputStreamReader isr = new InputStreamReader(url.openStream());
??? ??? ??? ??? // buffered the reader
??? ??? ??? ??? BufferedReader br = new BufferedReader(isr);
??? ??? ??? ???
??? ??? ??? ??? // store the temp string
??? ??? ??? ??? StringBuffer sb = new StringBuffer(10000);
??? ??? ??? ??? // temporary variable for each read
??? ??? ??? ??? String tmp="";
??? ??? ??? ???
??? ??? ??? ??? // read the content from reader
??? ??? ??? ??? while((tmp=br.readLine())!=null){
??? ??? ??? ??? ??? sb.append(tmp);
??? ??? ??? ??? }
??? ??? ??? ??? System.out.println(sb.toString());
??? ??? ??? ??? // match from the orginal string using? reglex express
??? ??? ??? ??? Pattern p = Pattern.compile("<<.*異人.*>>");
??? ??? ??? ??? Matcher m = p.matcher(sb.toString());??? ??? ??? ???
??? ??? ??? ???
??? ??? ??? ???
??? ??? ??? } catch (MalformedURLException e) {
??? ??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? ??? e.printStackTrace();
??? ??? ??? } catch (IOException e) {
??? ??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? ??? e.printStackTrace();
??? ??? ??? }
??? ??? }
??? }
}
看綠色代碼部分就可以知道了。
對于方法的改進,我們可以給parseUrl加上一個參數URL,那么,其他的相對應的部分也要做一些簡單的修改,代碼如下:
package org.zy.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ParseUrlUsingInnerClass2 {
???
??? public void parseUrl(URL url){
??? ??? Timer t = new Timer();
??? ??? t.schedule(new ParseTask(url),0,5*60*60);??? ???
??? }

???
??? public static void main(String[] args){
??? ??? ParseUrlUsingInnerClass2 puic = new ParseUrlUsingInnerClass2();
??? ???
??? ??? try {
??? ??? ??
URL url = new URL("http://post.baidu.com/f?kw=%D2%EC%C8%CB%B0%C1%CA%C0%C2%BC");
??? ??? ??? puic.parseUrl(url);

??? ??? } catch (MalformedURLException e) {
??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? e.printStackTrace();
??? ??? }
???
??? }
???
???
??? class ParseTask extends TimerTask{
??? ??? URL url;
??? ??? public ParseTask(URL url){
??? ??? ??? this.url = url;
??? ??? }

??? ??? public void run(){
??? ??? ??? System.out.println("runing");
??? ??? ??? try {
??? ??? ??? ??? // create url object
??? ??? ??? ??? //URL url = new URL("http://post.baidu.com/f?kw=%D2%EC%C8%CB%B0%C1%CA%C0%C2%BC");
??? ??? ??? ??? // get the input stream reader from the url
??? ??? ??? ??? InputStreamReader isr = new InputStreamReader(this.url.openStream());
??? ??? ??? ??? // buffered the reader
??? ??? ??? ??? BufferedReader br = new BufferedReader(isr);
??? ??? ??? ???
??? ??? ??? ??? // store the temp string
??? ??? ??? ??? StringBuffer sb = new StringBuffer(10000);
??? ??? ??? ??? // temporary variable for each read
??? ??? ??? ??? String tmp="";
??? ??? ??? ???
??? ??? ??? ??? // read the content from reader
??? ??? ??? ??? while((tmp=br.readLine())!=null){
??? ??? ??? ??? ??? sb.append(tmp);
??? ??? ??? ??? }
??? ??? ??? ??? System.out.println(sb.toString());
??? ??? ??? ??? // match from the orginal string using? reglex express
??? ??? ??? ??? Pattern p = Pattern.compile("<<.*異人.*>>");
??? ??? ??? ??? Matcher m = p.matcher(sb.toString());??? ??? ??? ???
??? ??? ??? ???
??? ??? ??? ???
??? ??? ??? } catch (MalformedURLException e) {
??? ??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? ??? e.printStackTrace();
??? ??? ??? } catch (IOException e) {
??? ??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? ??? e.printStackTrace();
??? ??? ??? }
??? ??? }
??? }
}

上面在用到此URL的地方和參數傳遞的地方都要做相應的修改,比如說
ParseTask類的構造器,都要做些修改。
上面的類的定義和方法的定義,已經可以實現減少部分耦合了。其實在run方法里面,如果從代碼重用的角度來看的話,那么我們還可以進行代碼改進和重構。
就上面的一個demo,我們也可以簡單的看到在類的設計中,我們還是有很多的問題要考慮,還是有很多的細節可以注意,來提高我們的代碼質量。
以上僅是一點簡單的理解。






zhyiwww 2007-10-25 11:19 發表評論
]]>
就一個面試題做的一個小小Demohttp://www.tkk7.com/zhyiwww/archive/2007/10/24/155590.htmlzhyiwwwzhyiwwwWed, 24 Oct 2007 06:34:00 GMThttp://www.tkk7.com/zhyiwww/archive/2007/10/24/155590.htmlhttp://www.tkk7.com/zhyiwww/comments/155590.htmlhttp://www.tkk7.com/zhyiwww/archive/2007/10/24/155590.html#Feedback1http://www.tkk7.com/zhyiwww/comments/commentRss/155590.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/155590.html
每5分鐘遍歷一下頁面(http://post.baidu.com/f?kw=%D2%EC%C8%CB%B0%C1%CA%C0%C2%BC),?
請統計頁面中"《"和"》"之間有多少個"異人"這兩個字,將這數值彈出一個alert并且發信給指定的郵件地址?
獲取頁面內所有地方的以"<<?>>"為標示的這個符號代表書名號,獲取之中的內容?
<<使用正則表達式>>
功能點:?
1)URL抓取頁面?
2)正則表達式匹配?
3)郵件系統調用?
請注意設計思路和代碼規范

就這個問題我寫了一個Demo,代碼如下:
package org.zy.demo;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
?*
?* @author zhangyi
?* zhyiwww@163.com
?*
?* 從url里面讀取內容,然后分析,用正則表達式匹配,返回結果
?*/

/*
??? ?每5分鐘遍歷一下頁面(http://post.baidu.com/f?kw=%D2%EC%C8%CB%B0%C1%CA%C0%C2%BC),
??? 請統計頁面中"《"和"》"之間有多少個"異人"這兩個字,將這數值彈出一個alert并且發信給指定的郵件地址
??? 獲取頁面內所有地方的以"<< >>"為標示的這個符號代表書名號,獲取之中的內容
??? <<使用正則表達式>>
??? 功能點:
??? 1)URL抓取頁面
??? 2)正則表達式匹配
??? 3)郵件系統調用
?*/
public class ParseUrlContent {
???
???
??? public static void main(String[] args){
??? ??? Timer t = new Timer();
??? ??? t.schedule(new ParseTask(),0,5*60*60);??? ???
??? }
???
???
}

class ParseTask extends TimerTask{
??? public void run(){
??? ??? System.out.println("runing");
??? ??? try {
??? ??? ??? // create url object
??? ??? ??? URL url = new URL("http://post.baidu.com/f?kw=%D2%EC%C8%CB%B0%C1%CA%C0%C2%BC");
??? ??? ??? // get the input stream reader from the url
??? ??? ??? InputStreamReader isr = new InputStreamReader(url.openStream());
??? ??? ??? // buffered the reader
??? ??? ??? BufferedReader br = new BufferedReader(isr);
??? ??? ???
??? ??? ??? // store the temp string
??? ??? ??? StringBuffer sb = new StringBuffer(10000);
??? ??? ??? // temporary variable for each read
??? ??? ??? String tmp="";
??? ??? ???
??? ??? ??? // read the content from reader
??? ??? ??? while((tmp=br.readLine())!=null){
??? ??? ??? ??? sb.append(tmp);
??? ??? ??? }
??? ??? ??? System.out.println(sb.toString());
??? ??? ??? // match from the orginal string using? reglex express
??? ??? ??? Pattern p = Pattern.compile("<<.*異人.*>>");
??? ??? ??? Matcher m = p.matcher(sb.toString());????? ??
??? ??? ??? // 此處可以做進一步的處理
??? ??? ???
??? ??? ???
??? ??? ???
??? ??? } catch (MalformedURLException e) {
??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? e.printStackTrace();
??? ??? } catch (IOException e) {
??? ??? ??? // TODO Auto-generated catch block
??? ??? ??? e.printStackTrace();
??? ??? }
??? }
}
實現思路:
1 從url讀取內容流
2 解析流,用正則表達式來匹配取出想要查找的內容

我沒有詳細的實現匹配的部分,其實,如果是要迭代的去遍歷內容里面所有的url,然后再解析也是可以實現的,就把上面的代碼封裝成一個方法parseUrl(URL url),然后,解析,迭代,就可以了。
這就是我的實現思路。



zhyiwww 2007-10-24 14:34 發表評論
]]>
回復兩個朋友的圖片裁剪問題http://www.tkk7.com/zhyiwww/archive/2007/10/18/153967.htmlzhyiwwwzhyiwwwThu, 18 Oct 2007 09:54:00 GMThttp://www.tkk7.com/zhyiwww/archive/2007/10/18/153967.htmlhttp://www.tkk7.com/zhyiwww/comments/153967.htmlhttp://www.tkk7.com/zhyiwww/archive/2007/10/18/153967.html#Feedback4http://www.tkk7.com/zhyiwww/comments/commentRss/153967.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/153967.html(zhyiwww@163.com? 轉載請注明出處 作者:zhyiwww )
最近,有兩個朋友在問我關于圖片裁剪的問題,不過以前的代碼找不到了,所以,就把完整的例子又整理了一下??梢詫崿F在一個完整的圖片上,根據需要,定位想要截取的圖片的左上角的坐標和圖片的大小,就可以取得該圖片。
完整的實現代碼如下:
package org.zy.app;

import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.util.Iterator;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import javax.imageio.ImageReader;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;

/**
?* @author zhangyi
?* date : 2007-10-18
?*/
public class SplitImage {

??? /**
??? ?* ????????? ?? ImageReader
??? ?*
??? ?* @param imgPath
??? ?* @throws IOException
??? ?*/

??? public void readImage() throws IOException {
??? ??? // get JPEG image reader iterator
??? ??? Iterator readers = ImageIO.getImageReadersByFormatName("jpg");
??? ??? System.out.println(readers);
??? ???
??? ??? // get image reader
??? ??? ImageReader reader = (ImageReader) readers.next();
??? ??? System.out.println(reader);

??? ??? // get original image input stream
??? ??? InputStream source = this.getClass().getResourceAsStream("img01.jpg");
??? ??? System.out.println("image input source is : " + source);
??? ???
??? ??? // get ImageInputStream of the image to split
??? ??? ImageInputStream iis = ImageIO.createImageInputStream(source);
??? ??? reader.setInput(iis, true);
??? ???
??? ??? // the image param
??? ??? ImageReadParam param = reader.getDefaultReadParam();
??? ??? int imageIndex = 0;
//??? ???
//??? ??? int half_width = reader.getWidth(imageIndex) / 2;
//??? ??? int half_height = reader.getHeight(imageIndex) / 2;

??? ??? // the coordinate and the size on the image that you want to split on
??? ??? Rectangle rect = new Rectangle(300, 490, 200, 100);
??? ??? param.setSourceRegion(rect);
??? ???
??? ??? BufferedImage bi = reader.read(0, param);
??? ???
??? ??? // write the split picture
??? ??? ImageIO.write(bi, "jpg", this.initDestFile());
??? }

??? public File initDestFile() throws IOException {
??? ??? File f = new File("c:\\img02.jpg");

??? ??? if (f.exists()) {
??? ??? ??? f.delete();
??? ??? }
??? ??? f.createNewFile();
??? ??? return f;
??? }

??? public static void main(String[] args) {
??? ??? SplitImage si = new SplitImage();
??? ??? try {
??? ??? ??? si.readImage();
??? ??? } catch (IOException e) {
??? ??? ??? System.out.println("exception");
??? ??? }
??? }
}

代碼下載SplitImage
這只是一個簡單的實現。當然,也可以在servlet端來實現此功能。


zhyiwww 2007-10-18 17:54 發表評論
]]>
properties文件的寫操作http://www.tkk7.com/zhyiwww/archive/2007/08/02/133960.htmlzhyiwwwzhyiwwwThu, 02 Aug 2007 03:26:00 GMThttp://www.tkk7.com/zhyiwww/archive/2007/08/02/133960.htmlhttp://www.tkk7.com/zhyiwww/comments/133960.htmlhttp://www.tkk7.com/zhyiwww/archive/2007/08/02/133960.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/133960.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/133960.html但是,有的時候,我們可能也需要動態的更新配置,那么怎么來實現對properties配置文件的更新操作呢.
這個問題其實很簡單,我們先看讀操作:
Properties p;
??? ??? try {
??? ??? ??? p = PropertiesReader
??? ??? ??? ??? ??? .readProperties("org/zy/common/parse/util/config.properties");
先載入配置文件,
String javaHome = p.getProperty("JAVA_HOME"));
通過getProperty()方法和關鍵字來實現屬性的檢索和返回.
那么,如何寫?
多的時候我們知道,我們首先要讀我們的配置文件流,那么寫的時候,我們也要先得到一個寫文件流.
由于是文本文件,所以我們使用FileWriter.
String path =p.getClass().getResource("/org/zy/common/parse/util/config.properties").getPath();
Writer w=new FileWriter(path);
此時,我們已經準備好了,要把更新的屬性寫到哪里,那么,如何寫?
有的時候,可能你是要更新某個屬性,有的時候,可能你要添加一個屬性.
可能你會使用w.write()方法來實現寫操作,沒有問題,但是,你以前的配置就完全沒有了,如果想保留的話,就只有完全寫一個新的文件.這中方法,對于更新某個屬性的值來說就稍微的麻煩一點.當然,可以用正則表達式來實現.
其實properties本身也給我們提供了方法.

p.setProperty("bb", "bb update string");
??? ??? ??? p.store(w,"bb");??? ???
??? ??? ??? w.close();
我們可以讀屬性,就可以設置屬性.
setProperty()方法就可以實現.
但是此時的更新只是在內存中,并沒有寫如文件.要寫入文件的話,就要調用store()方法.此時,我們關閉輸出流的話,數據已經持久化到了文件.
setProperty()中,如果你的屬性是文件里面沒有的屬性,那么,系統會進行追加操行,如果你的屬性,在系統中已經存在,那么系統就會進行更新操作.
例如:
你的配置文件是:
a=a
b=b
c=c
那么,如果你
p.setProperty("d","d");
那么,結果就是:
a=a
b=b
c=c
d=d
如果你執行
p.setProperty("a","d");
那么,結果就是:
a=d
b=b
c=c



zhyiwww 2007-08-02 11:26 發表評論
]]>
Java中實現圖片裁剪http://www.tkk7.com/zhyiwww/archive/2007/01/30/96767.htmlzhyiwwwzhyiwwwTue, 30 Jan 2007 09:41:00 GMThttp://www.tkk7.com/zhyiwww/archive/2007/01/30/96767.htmlhttp://www.tkk7.com/zhyiwww/comments/96767.htmlhttp://www.tkk7.com/zhyiwww/archive/2007/01/30/96767.html#Feedback7http://www.tkk7.com/zhyiwww/comments/commentRss/96767.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/96767.html閱讀全文

zhyiwww 2007-01-30 17:41 發表評論
]]>
XPath Study(轉載)http://www.tkk7.com/zhyiwww/archive/2006/10/24/77040.htmlzhyiwwwzhyiwwwTue, 24 Oct 2006 09:57:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/10/24/77040.htmlhttp://www.tkk7.com/zhyiwww/comments/77040.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/10/24/77040.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/77040.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/77040.html

XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document.
What You Should Already Know
Before you continue you should have a basic understanding of the following:
  • HTML / XHTML
  • XML / XML Namespaces

If you want to study these subjects first, find the tutorials on our Home page.
What is XPath?
  • XPath is a syntax for defining parts of an XML document
  • XPath uses path expressions to navigate in XML documents
  • XPath contains a library of standard functions
  • XPath is a major element in XSLT
  • XPath is a W3C Standard
XPath Path Expressions
XPath uses path expressions to select nodes or node-sets in an XML document. These path expressions look very much like the expressions you see when you work with a traditional computer file system.
XPath Standard Functions
XPath includes over 100 built-in functions. There are functions for string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values, and more.
XPath is Used in XSLT
XPath is a major element in the XSLT standard. Without XPath knowledge you will not be able to create XSLT documents.
You can read more about XSLT in our XSLT tutorial.
XQuery and XPointer are both built on XPath expressions. XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators.
You can read more about XQuery in our XQuery tutorial.
XPath is a W3C Standard
XPath became a W3C Recommendation 16. November 1999.
XPath was designed to be used by XSLT, XPointer and other XML parsing software.
You can read more about the XPath standard in our W3C tutorial. XPath Nodes

In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes.
XPath Terminology Nodes
In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes. XML documents are treated as trees of nodes. The root of the tree is called the document node (or root node).
Look at the following XML document:

<?xml version="1.0" encoding="ISO-8859-1"?>

<bookstore>

<book>

? <title >
? <author>J K. Rowling</author>

??<year>2005</year>

? <price>29.99</price>

</book>

</bookstore>

Example of nodes in the XML document above:

<bookstore>? (document node)

<author>J K. Rowling</author>? (element node)

>
Atomic values
Atomic values are nodes with no children or parent.
Example of atomic values:

J K. Rowling

"en"
Items
Items are atomic values or nodes.
Relationship of Nodes Parent
Each element and attribute has one parent.
In the following example; the book element is the parent of the title, author, year, and price:

<book>

? <title>Harry Potter</title>

? <author>J K. Rowling</author>

? <year>2005</year>

? <price>29.99</price>

</book>
Children
Element nodes may have zero, one or more children.
In the following example; the title, author, year, and price elements are all children of the book element:

<book>

? <title>Harry Potter</title>

? <author>J K. Rowling</author>

? <year>2005</year>

? <price>29.99</price>

</book>
Siblings
Nodes that have the same parent.
In the following example; the title, author, year, and price elements are all siblings:

<book>

? <title>Harry Potter</title>

? <author>J K. Rowling</author>

? <year>2005</year>

? <price>29.99</price>

</book>
Ancestors
A node's parent, parent's parent, etc.
In the following example; the ancestors of the title element are the book element and the bookstore element:

<bookstore>

<book>

? <title>Harry Potter</title>

? <author>J K. Rowling</author>

? <year>2005</year>

? <price>29.99</price>

</book>

</bookstore>
Descendants
A node's children, children's children, etc.
In the following example; descendants of the bookstore element are the book, title, author, year, and price elements:

<bookstore>

<book>

? <title>Harry Potter</title>

? <author>J K. Rowling</author>

? <year>2005</year>

? <price>29.99</price>

</book>

</bookstore>
XPath Syntax

XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.
The XML Example Document
We will use the following XML document in the examples below.

<?xml version="1.0" encoding="ISO-8859-1"?>

<bookstore>

<book>

? <title >
? <price>29.99</price>

</book>

<book>

? <title >
? <price>39.95</price>

</book>

</bookstore>

?
Selecting Nodes
XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below:

Expression

Description

nodename

Selects all child nodes of the node

/

Selects from the root node

//

Selects nodes in the document from the current node that match the selection no matter where they are

.

Selects the current node

..

Selects the parent of the current node

@

Selects attributes
Examples
In the table below we have listed some path expressions and the result of the expressions:

Path Expression

Result

bookstore

Selects all the child nodes of the bookstore element

/bookstore

Selects the root element bookstore
Note: If the path starts with a slash ( / ) it always represents an absolute path to an element!

bookstore/book

Selects all book elements that are children of bookstore

//book

Selects all book elements no matter where they are in the document

bookstore//book

Selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element

//@lang

Selects all attributes that are named lang

?
Predicates
Predicates are used to find a specific node or a node that contains a specific value.
Predicates are always embedded in square brackets. Examples
In the table below we have listed some path expressions with predicates and the result of the expressions:

Path Expression

Result

/bookstore/book[1]

Selects the first book element that is the child of the bookstore element

/bookstore/book[last()]

Selects the last book element that is the child of the bookstore element

/bookstore/book[last()-1]

Selects the last but one book element that is the child of the bookstore element

/bookstore/book[position()<3]

Selects the first two book elements that are children of the bookstore element

//title[@lang]

Selects all the title elements that have an attribute named lang

//title[@>

Selects all the title elements that have an attribute named lang with a value of 'eng'

/bookstore/book[price>35.00]

Selects all the book elements of the bookstore element that have a price element with a value greater than 35.00

/bookstore/book[price>35.00]/title

Selects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00

?
Selecting Unknown Nodes
XPath wildcards can be used to select unknown XML elements.

Wildcard

Description

*

Matches any element node

@*

Matches any attribute node

node()

Matches any node of any kind
Examples
In the table below we have listed some path expressions and the result of the expressions:

Path Expression

Result

/bookstore/*

Selects all the child nodes of the bookstore element

//*

Selects all elements in the document

//title[@*]

Selects all title elements which have any attribute

?
Selecting Several Paths
By using the | operator in an XPath expression you can select several paths. Examples
In the table below we have listed some path expressions and the result of the expressions:

Path Expression

Result

//book/title | //book/price

Selects all the title AND price elements of all book elements

//title | //price

Selects all the title AND price elements in the document

/bookstore/book/title | //price

Selects all the title elements of the book element of the bookstore element AND all the price elements in the document
XPath Axes
The XML Example Document
We will use the following XML document in the examples below.

<?xml version="1.0" encoding="ISO-8859-1"?>

<bookstore>

<book>

? <title >
? <price>29.99</price>

</book>

<book>

? <title >
? <price>39.95</price>

</book>

</bookstore>

?
XPath Axes
An axis defines a node-set relative to the current node.

AxisName

Result

ancestor

Selects all ancestors (parent, grandparent, etc.) of the current node

ancestor-or-self

Selects all ancestors (parent, grandparent, etc.) of the current node and the current node itself

attribute

Selects all attributes of the current node

child

Selects all children of the current node

descendant

Selects all descendants (children, grandchildren, etc.) of the current node

descendant-or-self

Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself

following

Selects everything in the document after the closing tag of the current node

following-sibling

Selects all siblings after the current node

namespace

Selects all namespace nodes of the current node

parent

Selects the parent of the current node

preceding

Selects everything in the document that is before the start tag of the current node

preceding-sibling

Selects all siblings before the current node

self

Selects the current node

?
Location Path Expression
A location path can be absolute or relative.
An absolute location path starts with a slash ( / ) and a relative location path does not. In both cases the location path consists of one or more steps, each separated by a slash:

An absolute location path:

/step/step/...

A relative location path:

step/step/...

Each step is evaluated against the nodes in the current node-set.
A step consists of:
  • an axis (defines the tree-relationship between the selected nodes and the current node)
  • a node-test (identifies a node within an axis)
  • zero or more predicates (to further refine the selected node-set)

The syntax for a location step is:

axisname::nodetest[predicate]
Examples

Example

Result

child::book

Selects all book nodes that are children of the current node

attribute::lang

Selects the lang attribute of the current node

child::*

Selects all children of the current node

attribute::*

Selects all attributes of the current node

child::text()

Selects all text child nodes of the current node

child::node()

Selects all child nodes of the current node

descendant::book

Selects all book descendants of the current node

ancestor::book

Selects all book ancestors of the current node

ancestor-or-self::book

Selects all book ancestors of the current node - and the current as well if it is a book node

child::*/child::price

Selects all price grandchildren of the current node
XPath Operators

An XPath expression returns either a node-set, a string, a Boolean, or a number.
XPath Operators
Below is a list of the operators that can be used in XPath expressions:

Operator

Description

Example

Return value

|

Computes two node-sets

//book | //cd

Returns a node-set with all book and cd elements

+

Addition

6 + 4

10

-

Subtraction

6 - 4

2

*

Multiplication

6 * 4

24

div

Division

8 div 4

2

=

Equal

price=9.80

true if price is 9.80false if price is 9.90

!=

Not equal

price!=9.80

true if price is 9.90false if price is 9.80

<?

Less than

price<9.80

true if price is 9.00false if price is 9.80

<=

Less than or equal to

price<=9.80

true if price is 9.00false if price is 9.90

>?

Greater than

price>9.80

true if price is 9.90false if price is 9.80

>=

Greater than or equal to

price>=9.80

true if price is 9.90false if price is 9.70

or

or

price=9.80 or price=9.70

true if price is 9.80false if price is 9.50

and

and

price>9.00 and price<9.90

true if price is 9.80false if price is 8.50

mod

Modulus (division remainder)

5 mod 2

1
XPath Examples

Let's try to learn some basic XPath syntax by looking at some examples.
The XML Example Document
We will use the following XML document in the examples below.
"books.xml":

<?xml version="1.0" encoding="ISO-8859-1"?>

<bookstore>

<book category="COOKING">

? <title >
? <author>Giada De Laurentiis</author>

? <year>2005</year>

? <price>30.00</price>

</book>

<book category="CHILDREN">

? <title >
? <author>J K. Rowling</author>

? <year>2005</year>

? <price>29.99</price>

</book>

<book category="WEB">

? <title >
? <author>James McGovern</author>

? <author>Per Bothner</author>

? <author>Kurt Cagle</author>

? <author>James Linn</author>

? <author>Vaidyanathan Nagarajan</author>

? <year>2003</year>

? <price>49.99</price>

</book>

<book category="WEB">

? <title >
? <author>Erik T. Ray</author>

? <year>2003</year>

? <price>39.95</price>

</book>

</bookstore>

View the "books.xml" file in your browser.
Selecting Nodes
We will use the Microsoft XMLDOM object to load the XML document and the selectNodes() function to select nodes from the XML document:

set xmlDoc=CreateObject("Microsoft.XMLDOM")

xmlDoc.async="false"

xmlDoc.load("books.xml")

xmlDoc.selectNodes(path expression)

?
Select all book Nodes
The following example selects all the book nodes under the bookstore element:

xmlDoc.selectNodes("/bookstore/book")

If you have IE 5 or higher you can try it yourself.
Select the First book Node
The following example selects only the first book node under the bookstore element:

xmlDoc.selectNodes("/bookstore/book[0]")

If you have IE 5 or higher you can try it yourself.
Note: IE 5 and 6 has implemented that [0] should be the first node, but according to the W3C standard it should have been [1]!!
Note: This is corrected in IE 6 SP2!
Select the prices
The following example selects the text from all the price nodes:

xmlDoc.selectNodes("/bookstore/book/price/text()")

If you have IE 5 or higher you can try it yourself.
Selecting price Nodes with Price>35
The following example selects all the price nodes with a price higher than 35:

xmlDoc.selectNodes("/bookstore/book[price>35]/price")

If you have IE 5 or higher you can try it yourself.
Selecting title Nodes with Price>35
The following example selects all the title nodes?with a price higher than 35:

xmlDoc.selectNodes("/bookstore/book[price>35]/title")

If you have IE 5 or higher you can try it yourself.
?
?
?
?
?

zhyiwww 2006-10-24 17:57 發表評論
]]>
ClassLoader分析(轉載)http://www.tkk7.com/zhyiwww/archive/2006/10/20/76406.htmlzhyiwwwzhyiwwwFri, 20 Oct 2006 08:23:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/10/20/76406.htmlhttp://www.tkk7.com/zhyiwww/comments/76406.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/10/20/76406.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/76406.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/76406.html閱讀全文

zhyiwww 2006-10-20 16:23 發表評論
]]>
如何將字符串轉換成Unicode編碼http://www.tkk7.com/zhyiwww/archive/2006/07/11/57686.htmlzhyiwwwzhyiwwwTue, 11 Jul 2006 09:35:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/07/11/57686.htmlhttp://www.tkk7.com/zhyiwww/comments/57686.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/07/11/57686.html#Feedback2http://www.tkk7.com/zhyiwww/comments/commentRss/57686.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/57686.html閱讀全文

zhyiwww 2006-07-11 17:35 發表評論
]]>
System.getProperty()參數大全http://www.tkk7.com/zhyiwww/archive/2006/06/02/50024.htmlzhyiwwwzhyiwwwFri, 02 Jun 2006 10:39:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/06/02/50024.htmlhttp://www.tkk7.com/zhyiwww/comments/50024.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/06/02/50024.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/50024.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/50024.html System.getProperty()參數大全

java.version????????????Java?Runtime?Environment?version
java.vendor????????????Java?Runtime?Environment?vendor
java.vendor.url????????????Java?vendor?URL
java.home????????????Java?installation?directory
java.vm.specification.version????????????????????Java?Virtual?Machine?specification?version
java.vm.specification.vendor????????????????????Java?Virtual?Machine?specification?vendor
java.vm.specification.name????????????????????Java?Virtual?Machine?specification?name
java.vm.version????????????Java?Virtual?Machine?implementation?version
java.vm.vendor????????????Java?Virtual?Machine?implementation?vendor
java.vm.name????????????Java?Virtual?Machine?implementation?name
java.specification.version????????????????Java?Runtime?Environment?specification?version
java.specification.vendor?????????????Java?Runtime?Environment?specification?vendor
java.specification.name????????Java?Runtime?Environment?specification?name
java.class.version????????????????????????Java?class?format?version?number
java.class.path??????????????????Java?class?path
java.library.path????????????????????????List?of?paths?to?search?when?loading?libraries
java.io.tmpdir????????????????Default?temp?file?path
java.compiler????????????Name?of?JIT?compiler?to?use
java.ext.dirs????????????Path?of?extension?directory?or?directories
os.name????????????????Operating?system?name
os.arch????????????????Operating?system?architecture
os.version????????????Operating?system?version
file.separator????????????File?separator?("/"?on?UNIX)
path.separator????????????Path?separator?(":"?on?UNIX)
line.separator????????????Line?separator?("\n"?on?UNIX)
user.name????????????User's?account?name
user.home????????????User's?home?directory
user.dir????????????????User's?current?working?directory


zhyiwww 2006-06-02 18:39 發表評論
]]>
去掉一個字符串數組中的重復項http://www.tkk7.com/zhyiwww/archive/2006/04/13/40810.htmlzhyiwwwzhyiwwwThu, 13 Apr 2006 01:38:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/04/13/40810.htmlhttp://www.tkk7.com/zhyiwww/comments/40810.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/04/13/40810.html#Feedback2http://www.tkk7.com/zhyiwww/comments/commentRss/40810.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/40810.html轉載 自http://www.tkk7.com/fastzch/archive/2006/04/11/40507.html?Pending=true#Post


1、去掉一個字符串數組中的重復項:(2006.04.11.)
原來采用的方法:
?1?String[]?rid?=?request.getParameterValues("noattRid");
?2?//需要用一個臨時的變量把過濾后的結果這個存起來
?3?String[]?ridFiltered?=?new?String[rid.length];
?4?????????int?index?=?0;
?5?????????for?(int?i?=?0;?i?<?rid.length;?i++)?{
?6?????????????if?(!this.isExistString(ridFiltered,?rid[i])&&!rid[i].equals(""))?{
?7?????????????????ridFiltered[index++]?=?rid[i];
?8?????????????}
?9?????????}
10?
11?//還需要用一個方法來判斷在結果中是否存在此項,如下
12??/**
13??????*?用于查找某個字符串是否在一個字符串數組中
14??????*?@param?dest?String[]
15??????*?@param?str?String
16??????*?return?boolean
17??????*/
18?
19?????public?boolean?isExistString(String[]?dest,?String?str)?{
20?????????boolean?flag?=?false;
21?????????for?(int?i?=?0;?i?<?dest.length;?i++)?{
22?????????????if?(str.equals(dest[i]))?{
23?????????????????flag?=?true;
24?????????????}
25?????????}
26?????????return?flag;
27?????}

看看,要多麻煩有多麻煩,來看看新方法:
1?String[]?s?=?request.getParameterValues("noattRid");
2?List?list?=?Arrays.asList(s);
3?Set?set?=?new?HashSet(list);
4?rid=(String?[])set.toArray();
簡簡單單的三行代碼即可搞定,無論是從程序的可讀性、優雅性還是效率方面都有很好的提升。
擴展:你同時還可以運用上面的方法還判斷三個字符串是否相等(可進一步擴展至多個,但是似乎不太有實際意義),例程如下:
1?String[]?s?=?{"one",?"two",?"two"};
2?List?list?=?Arrays.asList(s);
3?Set?set?=?new?HashSet(list);
4?System.out.println(list.size()?==?set.size());?//?false


zhyiwww 2006-04-13 09:38 發表評論
]]>
Vector和ArrayList的區別http://www.tkk7.com/zhyiwww/archive/2006/04/12/40554.htmlzhyiwwwzhyiwwwWed, 12 Apr 2006 01:09:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/04/12/40554.htmlhttp://www.tkk7.com/zhyiwww/comments/40554.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/04/12/40554.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/40554.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/40554.html Vector ArrayList 的區別

       (這篇文章是從網上摘錄,地址忘了,如涉及版權請和我聯系zhyiwww@163.com)

1.        vector 是線程同步的,所以它也是線程安全的,而 arraylist 是線程異步的,是不安全的。如果不考慮到線程的安全因素,一般用 arraylist 效率比較高。

 

2.        如果集合中的元素的數目大于目前集合數組的長度時, vector 增長率為目前數組長度的 100%, arraylist 增長率為目前數組長度的 50%. 如過在集合中使用數據量比較大的數據,用 vector 有一定的優勢。

 

3.         如果查找一個指定位置的數據, vector arraylist 使用的時間是相同的,都是 0(1), 這個時候使用 vector arraylist 都可以。而如果移動一個指定位置的數據花費的時間為 0(n-i)n 為總長度,這個時候就應該考慮到使用 linklist, 因為它移動一個指定位置的數據所花費的時間為 0(1), 而查詢一個指定位置的數據時花費的時間為 0(i) 。

 

 

另:

如果你注意到對Vector和List的所開始支持的Java版本你就應該可以找到答案了。Java對Vector的支持since 1.0;對List則是since 1.2。這兩個版本之間,sun對于java api做了很多的改動,其中的一個refactoring就是提出了所謂的Collection FrameWork,List就是在那個時候被introduced,它完全符合1.2版本的collection framework,而Vector則是在Colleciton framework出現之前就已經存在了,但java api并沒有將Vector變成Deprecated,主要是backward compatiable的問題,最終JCP將vector做了refactoring的處理,讓它符合所定制的Collection framework了事。另外,Hashtable和HashMap的區別是同樣的道理。

 

結論:

盡量采用 List HashMap rather than Vector&Hashtable

 

 



zhyiwww 2006-04-12 09:09 發表評論
]]>
深入理解abstract class和interfacehttp://www.tkk7.com/zhyiwww/archive/2006/04/05/39444.htmlzhyiwwwzhyiwwwWed, 05 Apr 2006 10:03:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/04/05/39444.htmlhttp://www.tkk7.com/zhyiwww/comments/39444.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/04/05/39444.html#Feedback1http://www.tkk7.com/zhyiwww/comments/commentRss/39444.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/39444.html轉載自 http://bbs.java.ccidnet.com/htm_data/2/0603/1080.html

abstract class和interface是Java語言中對于抽象類定義進行支持的兩種機制,正是由于這兩種機制的存在,才賦予了Java強大的面向對象能力。abstract class和interface之間在對于抽象類定義的支持方面具有很大的相似性,甚至可以相互替換,因此很多開發者在進行抽象類定義時對于abstract class和interface的選擇顯得比較隨意。其實,兩者之間還是有很大的區別的,對于它們的選擇甚至反映出對于問題領域本質的理解、對于設計意圖的理解是否正確、合理。本文將對它們之間的區別進行一番剖析,試圖給開發者提供一個在二者之間進行選擇的依據。

理解抽象類

abstract class和interface在Java語言中都是用來進行抽象類(本文中的抽象類并非從abstract class翻譯而來,它表示的是一個抽象體,而abstract class為Java語言中用于定義抽象類的一種方法,請讀者注意區分)定義的,那么什么是抽象類,使用抽象類能為我們帶來什么好處呢?

在面向對象的概念中,我們知道所有的對象都是通過類來描繪的,但是反過來卻不是這樣。并不是所有的類都是用來描繪對象的,如果一個類中沒有包含足夠的信息來描繪一個具體的對象,這樣的類就是抽象類。抽象類往往用來表征我們在對問題領域進行分析、設計中得出的抽象概念,是對一系列看上去不同,但是本質上相同的具體概念的抽象。比如:如果我們進行一個圖形編輯軟件的開發,就會發現問題領域存在著圓、三角形這樣一些具體概念,它們是不同的,但是它們又都屬于形狀這樣一個概念,形狀這個概念在問題領域是不存在的,它就是一個抽象概念。正是因為抽象的概念在問題領域沒有對應的具體概念,所以用以表征抽象概念的抽象類是不能夠實例化的。

在面向對象領域,抽象類主要用來進行類型隱藏。我們可以構造出一個固定的一組行為的抽象描述,但是這組行為卻能夠有任意個可能的具體實現方式。這個抽象描述就是抽象類,而這一組任意個可能的具體實現則表現為所有可能的派生類。模塊可以操作一個抽象體。由于模塊依賴于一個固定的抽象體,因此它可以是不允許修改的;同時,通過從這個抽象體派生,也可擴展此模塊的行為功能。熟悉OCP的讀者一定知道,為了能夠實現面向對象設計的一個最核心的原則OCP(Open-Closed Principle),抽象類是其中的關鍵所在。

從語法定義層面看abstract class和interface

在語法層面,Java語言對于abstract class和interface給出了不同的定義方式,下面以定義一個名為Demo的抽象類為例來說明這種不同。
使用abstract class的方式定義Demo抽象類的方式如下:

abstract class Demo {
abstract void method1();
abstract void method2();
…
}

使用interface的方式定義Demo抽象類的方式如下:

interface Demo {
void method1();
void method2();
…
}

在abstract class方式中,Demo可以有自己的數據成員,也可以有非abstarct的成員方法,而在interface方式的實現中,Demo只能夠有靜態的不能被修改的數據成員(也就是必須是static final的,不過在interface中一般不定義數據成員),所有的成員方法都是abstract的。從某種意義上說,interface是一種特殊形式的abstract class。

從編程的角度來看,abstract class和interface都可以用來實現"design by contract"的思想。但是在具體的使用上面還是有一些區別的。

首先,abstract class在Java語言中表示的是一種繼承關系,一個類只能使用一次繼承關系。但是,一個類卻可以實現多個interface。也許,這是Java語言的設計者在考慮Java對于多重繼承的支持方面的一種折中考慮吧。

其次,在abstract class的定義中,我們可以賦予方法的默認行為。但是在interface的定義中,方法卻不能擁有默認行為,為了繞過這個限制,必須使用委托,但是這會 增加一些復雜性,有時會造成很大的麻煩。

在抽象類中不能定義默認行為還存在另一個比較嚴重的問題,那就是可能會造成維護上的麻煩。因為如果后來想修改類的界面(一般通過abstract class或者interface來表示)以適應新的情況(比如,添加新的方法或者給已用的方法中添加新的參數)時,就會非常的麻煩,可能要花費很多的時間(對于派生類很多的情況,尤為如此)。但是如果界面是通過abstract class來實現的,那么可能就只需要修改定義在abstract class中的默認行為就可以了。

同樣,如果不能在抽象類中定義默認行為,就會導致同樣的方法實現出現在該抽象類的每一個派生類中,違反了"one rule,one place"原則,造成代碼重復,同樣不利于以后的維護。因此,在abstract class和interface間進行選擇時要非常的小心。

從設計理念層面看abstract class和interface

上面主要從語法定義和編程的角度論述了abstract class和interface的區別,這些層面的區別是比較低層次的、非本質的。本小節將從另一個層面:abstract class和interface所反映出的設計理念,來分析一下二者的區別。作者認為,從這個層面進行分析才能理解二者概念的本質所在。

前面已經提到過,abstarct class在Java語言中體現了一種繼承關系,要想使得繼承關系合理,父類和派生類之間必須存在"is a"關系,即父類和派生類在概念本質上應該是相同的(參考文獻〔3〕中有關于"is a"關系的大篇幅深入的論述,有興趣的讀者可以參考)。對于interface 來說則不然,并不要求interface的實現者和interface定義在概念本質上是一致的,僅僅是實現了interface定義的契約而已。為了使論述便于理解,下面將通過一個簡單的實例進行說明。

考慮這樣一個例子,假設在我們的問題領域中有一個關于Door的抽象概念,該Door具有執行兩個動作open和close,此時我們可以通過abstract class或者interface來定義一個表示該抽象概念的類型,定義方式分別如下所示:

使用abstract class方式定義Door:

abstract class Door {
abstract void open();
abstract void close();
}

使用interface方式定義Door:

interface Door {
void open();
void close();
}

其他具體的Door類型可以extends使用abstract class方式定義的Door或者implements使用interface方式定義的Door。看起來好像使用abstract class和interface沒有大的區別。

如果現在要求Door還要具有報警的功能。我們該如何設計針對該例子的類結構呢(在本例中,主要是為了展示abstract class和interface反映在設計理念上的區別,其他方面無關的問題都做了簡化或者忽略)?下面將羅列出可能的解決方案,并從設計理念層面對這些不同的方案進行分析。

解決方案一:

簡單的在Door的定義中增加一個alarm方法,如下:

abstract class Door {
abstract void open();
abstract void close();
abstract void alarm();
}

或者

interface Door {
void open();
void close();
void alarm();
}

那么具有報警功能的AlarmDoor的定義方式如下:

class AlarmDoor extends Door {
void open() { … }
void close() { … }
void alarm() { … }
}

或者

class AlarmDoor implements Door {
void open() { … }
void close() { … }
void alarm() { … }
}

這種方法違反了面向對象設計中的一個核心原則ISP(Interface Segregation Priciple),在Door的定義中把Door概念本身固有的行為方法和另外一個概念"報警器"的行為方法混在了一起。這樣引起的一個問題是那些僅僅依賴于Door這個概念的模塊會因為"報警器"這個概念的改變(比如:修改alarm方法的參數)而改變,反之依然。

解決方案二:

既然open、close和alarm屬于兩個不同的概念,根據ISP原則應該把它們分別定義在代表這兩個概念的抽象類中。定義方式有:這兩個概念都使用abstract class方式定義;兩個概念都使用interface方式定義;一個概念使用abstract class方式定義,另一個概念使用interface方式定義。

顯然,由于Java語言不支持多重繼承,所以兩個概念都使用abstract class方式定義是不可行的。后面兩種方式都是可行的,但是對于它們的選擇卻反映出對于問題領域中的概念本質的理解、對于設計意圖的反映是否正確、合理。我們一一來分析、說明。

如果兩個概念都使用interface方式來定義,那么就反映出兩個問題:1、我們可能沒有理解清楚問題領域,AlarmDoor在概念本質上到底是Door還是報警器?2、如果我們對于問題領域的理解沒有問題,比如:我們通過對于問題領域的分析發現AlarmDoor在概念本質上和Door是一致的,那么我們在實現時就沒有能夠正確的揭示我們的設計意圖,因為在這兩個概念的定義上(均使用interface方式定義)反映不出上述含義。

如果我們對于問題領域的理解是:AlarmDoor在概念本質上是Door,同時它有具有報警的功能。我們該如何來設計、實現來明確的反映出我們的意思呢?前面已經說過,abstract class在Java語言中表示一種繼承關系,而繼承關系在本質上是"is a"關系。所以對于Door這個概念,我們應該使用abstarct class方式來定義。另外,AlarmDoor又具有報警功能,說明它又能夠完成報警概念中定義的行為,所以報警概念可以通過interface方式定義。如下所示:

abstract class Door {
abstract void open();
abstract void close();
}
interface Alarm {
void alarm();
}
class AlarmDoor extends Door implements Alarm {
void open() { … }
void close() { … }
void alarm() { … }
}

這種實現方式基本上能夠明確的反映出我們對于問題領域的理解,正確的揭示我們的設計意圖。其實abstract class表示的是"is a"關系,interface表示的是"like a"關系,大家在選擇時可以作為一個依據,當然這是建立在對問題領域的理解上的,比如:如果我們認為AlarmDoor在概念本質上是報警器,同時又具有Door的功能,那么上述的定義方式就要反過來了。

結論

abstract class和interface是Java語言中的兩種定義抽象類的方式,它們之間有很大的相似性。但是對于它們的選擇卻又往往反映出對于問題領域中的概念本質的理解、對于設計意圖的反映是否正確、合理,因為它們表現了概念間的不同的關系(雖然都能夠實現需求的功能)。這其實也是語言的一種的慣用法,希望讀者朋友能夠細細體會。



zhyiwww 2006-04-05 18:03 發表評論
]]>
Set中的元素為什么不允許重復http://www.tkk7.com/zhyiwww/archive/2006/03/30/38193.htmlzhyiwwwzhyiwwwThu, 30 Mar 2006 01:41:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/03/30/38193.htmlhttp://www.tkk7.com/zhyiwww/comments/38193.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/03/30/38193.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/38193.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/38193.html Set 中的元素為什么不允許重復

?????? 版權所有,轉載請聲明出處 zhyiwww@163.com

?

為了弄清楚這個問題 , 我又看了一遍 Collection 部分 , 并且看了些其中的源碼 , 覺得對其中的實現又明白了一點 , 現在說出來和大家共享 .

我們先看一下 Set 類的關系圖:

hashset.png
現在我們就從
Set 說起。

Set 接口為我們提供了一個 add() 方法,以讓我們添加元素。所以我們看一下在其實現類 HashSet 中是如何實現的呢?

我們看 HashSet 中的 add() 方法實現;

??? public boolean add( E o ) {

?????? ?????? return? map.put(o, PRESENT)==null;

}

你可能回問怎么回出來 map 了呢?

Map 又是一個什么變量呢?

我們來看 map 是在在哪定義的。原來,在 HashSet 中定義了這樣的兩個變量:

??? private transient HashMap<E,Object> map;

??? private static final Object PRESENT = new Object();

我們再看一下上面的 add() 方法。

map.put(o, PRESENT)==null

實際執行的是 map 的方法,并且我們添加的對象是 map 中的 key,value 是執行的同一個對象 PRESENT.

因為map中的key是不允許重復的,所以set中的元素不能重復。

?

下面我們再看一下, map 又是如何保證其 key 不重復的呢?

?hashmap.png

現在我們看一下 map 中的 put() 方法的實現:

HashMap 實現了 map ,在 HashMap 中是這樣實現的:

??? public V put(K key, V value) {

????? K k = maskNull(key);

??????? int hash = hash(k);

??????? int i = indexFor(hash, table.length);

??????? for (Entry<K,V> e = table[i]; e != null; e = e.next) {

??????????? if (e.hash == hash && eq(k, e.key)) {

??????????????? V oldValue = e.value;

??????????????? e.value = value;

??????????????? e.recordAccess(this);

??????????????? return oldValue;

??????????? }

??????? }

?

??????? modCount++;

??????? addEntry(hash, k, value, i);

??????? return null;

??? }

我們我們按照方法的執行一步一步的來看一下,其實現的過程。

K k = maskNull(key);

這一步是要判斷當前的要添加的對象的 key 是否為空,如果為空的話,那么就生成一個新的對象作為其 key 。實現如下:

??? static final Object NULL_KEY = new Object();

???? * Returns internal representation for key. Use NULL_KEY if key is null.

??? static <T> T maskNull(T key) {

??????? return key == null ? (T)NULL_KEY : key;

??? }

之后

int hash = hash(k);

我們看一下 hash() 方法的實現:

??? static int hash(Object x) {

??????? int h = x.hashCode();

??????? h += ~(h << 9);

??????? h ^=? (h >>> 14);

??????? h +=? (h << 4);

??????? h ^=? (h >>> 10);

??????? return h;

??? }

這一步其實是要得到當前要添加對象的 hashcode, 方法中,首先通過 int h = x.hashCode() 取得了當前的要添加對象的 hashcode, 然后

??????? h += ~(h << 9);

??????? h ^=? (h >>> 14);

??????? h +=? (h << 4);

??????? h ^=? (h >>> 10);

生成一個新的 hashcode.

接著執行的是

(從此處開始,我理解的比較膚淺,請看到此出的朋友多多指點)

int i = indexFor(hash, table.length);

這個方法是要 Returns index for hash code h.

??? static int indexFor(int h, int length) {

??????? return h & (length-1);

??? }

????? 下面就要根據 hashmap 中的元素逐個的比較,看是否相同,如果不同就回添加一個新的元素。是通過循環判斷來實現的。

??????? for (Entry<K,V> e = table[i]; e != null; e = e.next) {

??????????? if (e.hash == hash && eq(k, e.key)) {

??????????????? V oldValue = e.value;

??????????????? e.value = value;

??????????????? e.recordAccess(this);

這句我的理解是:在內存中的可以訪問元素又多了一個。也就是說,添加之后,可以通過hashmap來訪問此元素了。

???????? ???????return oldValue;

??????????? }

??????? }

通過循環判斷是否有完全相同的對象,包括 hashcode value 值。如果已經存在就返回其值,如果不存在就執行一下操作。

??????? modCount++;

??????? addEntry(hash, k, value, i);

??????? return null;

對象不存在,首先修改 hashmap 的修改次數,即 modCount 1. 然后將對象添加到數組中。

??? void addEntry(int hash, K key, V value, int bucketIndex) {

????? Entry<K,V> e = table[bucketIndex];

??????? table[bucketIndex] = new Entry<K,V>(hash, key, value, e);

??????? if (size++ >= threshold)

??????????? resize(2 * table.length);

}

仍然是數組,我們來看一下 , hashmap 中用來存放對象的數組的定義:

?? ?transient Entry[] table;

至此,我想大家也許應該明白了,為什么在 set 中是不允許存放重復值的。

通過才的分析,我們可以看到, map 的一些特征:

1.?????? map 中也是不能存放完全相同的元素的

2.?????? 如果你存入的對象的 key 值已經存在的話,那么新的 value 將會取代老的 value 值,但是并不會添加新的元素進去。

我們可以通過一個測試程序來證明這一點:

? public void mapTest() {

??? Map m = new HashMap();

??? /**

???? * we? can? put? the? int? 1 and the? value? 1? into? the? map

???? * but? we? cannot? get? the? 1 as? int? from the map

???? * why ?

???? * we? only? get? the? 1? as? integer? from? the map,

???? * so? we? only? get the object? from the map,if we? put the? value? into

???? * the map,we? will get one? instance of? the wrapper? of? that

???? */

??? m.put(1, 1);

??? //int i = m.get(1);

??? Integer i = (Integer) m.get(1);

??? System.out.println(i);

?

??? m.put(1, 1);

??? m.put(1, 1);

??? System.out.println("map?? :??? " + m);

??? System.out.println("map? size??? :?? " + m.size());

??? m.put(1, 2);

??? System.out.println("map?? :??? " + m);

??? System.out.println("map? size??? :?? " + m.size());

? }

運行的結果是:

map?? :??? {1=1}

map? size??? :?? 1

map?? :??? {1=2}

map? size?? ?:?? 1

希望此文能大家有所幫助。



zhyiwww 2006-03-30 09:41 發表評論
]]>
程序設計的主要目標:將變動的事物和不變的事物隔離開來http://www.tkk7.com/zhyiwww/archive/2006/03/29/38010.htmlzhyiwwwzhyiwwwWed, 29 Mar 2006 03:51:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/03/29/38010.htmlhttp://www.tkk7.com/zhyiwww/comments/38010.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/03/29/38010.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/38010.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/38010.html將變動的事物和不變的事物隔離開來

zhyiwww 2006-03-29 11:51 發表評論
]]>
一個小錯誤--在方法中定義static 變量http://www.tkk7.com/zhyiwww/archive/2006/03/29/37996.htmlzhyiwwwzhyiwwwWed, 29 Mar 2006 02:50:00 GMThttp://www.tkk7.com/zhyiwww/archive/2006/03/29/37996.htmlhttp://www.tkk7.com/zhyiwww/comments/37996.htmlhttp://www.tkk7.com/zhyiwww/archive/2006/03/29/37996.html#Feedback0http://www.tkk7.com/zhyiwww/comments/commentRss/37996.htmlhttp://www.tkk7.com/zhyiwww/services/trackbacks/37996.html是在方法中定義一個static變量,問程序運行會出現什么問題?
public void amethod() {
    static int i=10;
    System.out.println(i);
  }
如果你曾實驗過的話,就知道,如果你使用eclipse或jbuilder的話,那么,你的程序不用編譯就回出現錯誤
Errors:  illegal  start of expression  at  line  69 .



zhyiwww 2006-03-29 10:50 發表評論
]]>
主站蜘蛛池模板: 午夜a级成人免费毛片| 国产日韩一区二区三免费高清| 亚洲精品无码av中文字幕| 亚洲宅男天堂a在线| 亚洲最大黄色网站| 亚洲av无码国产综合专区| 亚洲一区二区三区免费在线观看| 亚洲精品电影天堂网| 亚洲免费观看在线视频| 亚洲人成人77777网站不卡| 7777久久亚洲中文字幕| 亚洲人成欧美中文字幕| 国产精品亚洲AV三区| 人体大胆做受免费视频| 成人免费一区二区三区| 男女午夜24式免费视频| 99久久久国产精品免费牛牛四川 | 亚洲人成网77777亚洲色| 精品亚洲综合久久中文字幕| 亚洲AV无码精品色午夜在线观看 | 精品久久洲久久久久护士免费| 国产精品二区三区免费播放心| 青青青国产色视频在线观看国产亚洲欧洲国产综合 | 7777久久亚洲中文字幕蜜桃| 亚洲国产av一区二区三区丶| 亚洲午夜无码久久| 三级片免费观看久久| 国精产品一区一区三区免费视频| 最近免费最新高清中文字幕韩国| 少妇高潮太爽了在线观看免费| 国产精品色午夜视频免费看| 久久久无码精品亚洲日韩软件| 亚洲第一精品福利| 亚洲午夜无码久久久久小说| 人成电影网在线观看免费| 日日麻批免费40分钟无码 | 久青草视频97国内免费影视| 18禁成人网站免费观看| 全免费a级毛片免费看无码| 亚洲日韩人妻第一页| 亚洲精品白色在线发布|