2006年01月



    摘要:blog 停止更新!    (全文共100字)——点击此处阅读全文



由于软件下载中的一篇文章出现连续英文安符太长,撑坏了版面.见下图!


图一


图二





    摘要:Sun Java 认证相关信息.    (全文共3143字)——点击此处阅读全文




    摘要:chapter 9 practice 8 : create a Cats container and test it.    (全文共880字)——点击此处阅读全文




    摘要:chapter 9 practice 7: the problem of using inheritance instead of composition    (全文共839字)——点击此处阅读全文




    摘要:chater 9 practice 6 : prove that there is nothing else can be add to MouseList except Mouse    (全文共959字)——点击此处阅读全文




    摘要:chapter 9 practice 5: test ArrayList and LinkedList.    (全文共750字)——点击此处阅读全文



//: chapter 9 practice 4 : fill a map with Gerbil
// tip: I use the Pair class out of com.bruceeckel.util,
// so we need to change the Pair constuctor to be public.
import java.util.*;
import com.bruceeckel.util.*;

class Gerbil{
 private int gerbilNumber;
 Gerbil(int x){
  gerbilNumber = x;
 }
 public void hop(){
  System.out.println("Gerbil #" + gerbilNumber + " is hopping");
 }
 //to be the name of the object
 public String name(){
  return "Gerbil #" + gerbilNumber;
 }
 //to be print
 public String toString(){
  return "Gerbil #" + gerbilNumber + "reference";
 }
}

class GerbilGenerator implements MapGenerator{
 private Arrays2.RandIntGenerator gen;
 private Gerbil gerbil;
 public GerbilGenerator(int mod){
  gen = new Arrays2.RandIntGenerator(mod);
 }
 public Pair next(){
  gerbil = new Gerbil(gen.next());
  return new Pair(gerbil.name(),gerbil);
 }
}

public class P4{
 public static void main(String[] args){
  HashMap hm = new HashMap();
  // default Gerbil Ubound number
  int mod=100;
  // user give the Ubound number
  if (args.length != 0)
   mod = Integer.parseInt(args[0]);
  Collections2.fill(hm,new GerbilGenerator(mod),10);
  Iterator it = hm.keySet().iterator();
  while(it.hasNext()){
   Object gkey = it.next();
   System.out.println(gkey);
   ((Gerbil)hm.get(gkey)).hop();
  }
 }
}





    摘要:保存为Global.asa,存放在网站的根目录下即可.    (全文共6722字)——点击此处阅读全文



//: c9:p3
// Practice using ArrayList : using iterator().

import java.util.*;

class Gerbil {
 private int gerbilNumber;
 Gerbil(int x) {
  gerbilNumber = x;
 }
 void hop() {
  System.out.println("# gerbil " + gerbilNumber + " is hopping");
 }
}
public class P3 {
 private static int t;
 public static void main(String[] args) {
  if(args.length != 0)
   t = Integer.parseInt(args[0]);
  else
   t = 10;
  ArrayList al = new ArrayList();
  for(int i = 1; i < t; i++)
   al.add(new Gerbil(i));
  Iterator it = al.iterator();
  while(it.hasNext())
   ((Gerbil)it.next()).hop();
 }
}





    摘要:Practice using ArrayList : add object and get object.    (全文共879字)——点击此处阅读全文




    摘要:完成了一个网站!    (全文共226字)——点击此处阅读全文




    摘要:还原OE地址簿    (全文共362字)——点击此处阅读全文




    摘要:Windows Server 2003 的网上邻居!    (全文共117字)——点击此处阅读全文




    摘要:asp 备忘.    (全文共329字)——点击此处阅读全文




    摘要:access 使用中的BUG    (全文共416字)——点击此处阅读全文




    摘要:chapter 9 practice 1 : using Arrays2 to fill and print a double array    (全文共638字)——点击此处阅读全文




    摘要:chapter 8 pratice 29 : outer class and inner class can access private elements each other    (全文共1088字)——点击此处阅读全文




    摘要:Add new event to GreenhouseControls    (全文共7720字)——点击此处阅读全文



本文原创,转载请注明出处;载于商业用途需经本人书面许可.

用网络来查找资料相当方便是人所皆知的事实,找到相关的文章,自然是拷贝粘贴啦,当然,拷贝的时候还需要点技巧,直接拷进Word文档有时候是相当麻烦的,比较方便的做法是先拷进记事本,然后再转入word,这样做的好处是除去表格以等网页元素,只拷贝“纯文本”。然而这样做还不够彻底:网页上的文字,有时候为了显示的美观,段落之间往往存在着空白行,这就使得拷下来的文章变得篇幅巨大,打印出来极不美观。面对只有个位数的资料,删除这些空行自然相当简单,手动一下就可以了,但当你面对着两位数的,甚至三位数的文章时,那简直就是灾难!当然,Word这么成熟的编辑软件,理应有方便的方法使用达到删除这些空行的目的!下面就介绍两种简单实用的方法。

方法一:查找替换法。相信这个方法是比较简单实用的,但用起来有一点儿麻烦。在输入查找字符的时候,换段符是这样表示的“^p”,手动换段(即shift+enter产生的符号)符是这样表示的“^l”,其中的"l"是小字的L。那么,替换的方法就是把所有的“^l”先换成“^p”,再将所有的“^p^p”换成“^p”。当然,在此操作之前,需要先把所有的空格都替换掉。

方法二:使用宏。宏其实是个好东西,只不过平常比较少人去接触它。并且出于安全性的考虑,Word默认的情况下是没有启用它的,需要先进行安全性设置,允许你自己选择是启用宏,还是不启用宏。它其实是一段VB小程序,事实上,Word的大部分功能就是使用宏编写出来的,只不过它们已经经过内置设定,使用者在GUI界面操作它们,根本不知道它们实际上是怎么来的。知道了这些知识背景之后,对宏大概没有那么抵抗心理了吧?好,只要把下面这段VB代码,复制到你的自定义宏库中去,然后运行它,就可以一键消除所有的空行了!具体办法:

1,打开WORD,打开“工具-宏-Visual Basic编辑器”,在Visual编辑器左边,你会看到工程-project栏目,栏目中一般会包含两个项,一个是“Normal”,另一个是“Project(Doc1)”,其中(Doc1)是你所打开的WORD文档的名称。前者为WORD共用程序库,后者为单一文档程序库。如果你把代码写在前者里面,那你本机在本机的其它文档中,也可以使用,是“共用”的程序库;若为后者,则只有所在文档才能使用,同时,也可以能过拷贝具体文档,将宏带者,前者则不行。

2,双击期中的“Thisdocument”(两者任选),打开代码输入窗口,在其中输入以下代码:

Sub KillEmptyRows()
    '删除空行,by不见不散,2006-1-15
    Dim p As Paragraph
    Dim r As Range
    Dim s As String
    Dim l As Long
    For Each p In ActiveDocument.Paragraphs
        Set r = p.Range
        s = CStr(r.Text)
        l = Asc(s)
        If (l = 13 Or l = 11) Then r.Text = ""
    Next p
End Sub

保存,关闭Visual Basic编辑器,返回WORD界面。此时再打开“工具-宏”,在“宏的位置”中选择“所有模版和活动文档”(因为不知道你是存在模版中,还是在单个文档中,此选择可以保证两者皆可显示),你会在上方窗口的“宏名”中看到一个KillEmptyRows的宏,选择运行即可!

两种方法,各有优缺点,选用哪个,就要看你自己的喜好咯!





    摘要:Anonymous inner class and callbacks    (全文共2098字)——点击此处阅读全文




    摘要:another implementation of Selector in Sequence.java    (全文共2743字)——点击此处阅读全文




    摘要:strange to put this practice here!    (全文共1016字)——点击此处阅读全文




    摘要:chapter 8 practice 24 : inherit inner class with inner class    (全文共1313字)——点击此处阅读全文




    摘要:chapter 8 practice 23 : simple inner class and it's object    (全文共504字)——点击此处阅读全文




    摘要:2 level inner class    (全文共1369字)——点击此处阅读全文



//: c8/P21

interface Sport {
 // inner class can be set in interface:
 // because inner class juse use the name space of the interface.
 static class Running{
  void keepHealth(){ System.out.println("Running can keep you healthy"); }
 }
}

public class P21 {
 class EmptyHandSport implements Sport {}
 public static void main(String[] args) {
  // to get the reference of the static inner class
  // just use new statement:
  Sport.Running sr = new Sport.Running();
  sr.keepHealth();
 }
}

Also,non-static inner class can be treated like static inner class in interface!

//: c8/P21a

interface Sport {
 // inner class can be set in interface:
 // because inner class juse use the name space of the interface.
 class Running{
  void keepHealth(){ System.out.println("Running can keep you healthy"); }
 }
}

public class P21a {
 class EmptyHandSport implements Sport {}
 public static void main(String[] args) {
  // to get the reference of the static inner class
  // just use new statement:
  Sport.Running sr = new Sport.Running();
  sr.keepHealth();
 }
}





    摘要:chapter 8 / practice 20 : simple static inner class    (全文共457字)——点击此处阅读全文




    摘要:chapter 8 practice 19 : repeat practice 18 and use anonymous inner class instead    (全文共1368字)——点击此处阅读全文




    摘要:chapter 8 practice 18 : inner class's effect    (全文共1077字)——点击此处阅读全文



打开.chm文件,发现只有左边导航栏可以显示,右边显示为"无法打开页面".文是好的没错,在别的机器上都试过正常打开.那么,是什么原因造成的呢?

原来是这样的(引自http://support.microsoft.com/kb/896054/zh-cn):"Windows Server 2003 SP1 及安全更新 896358 和 840315 中包括对 InfoTech 协议的更改。引入这些更改的目的是为了减少 HTML 帮助中的安全漏洞。"简单说来,就是监于安全原因,微软的补订程序禁止显示这一类chm文档.(-_-|||)

解决办法1(来自上边链接):把下边内容存为reg文件,运行导入注册表即可.

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000003


注意,导入上面注册表文件后,系统再次允许chm文件访问相应的网络资源,也就是说计算机再次产生使用风险(如果你没有连接网络,那放心用吧).

更详细的资料请查阅:http://support.microsoft.com/kb/896054/zh-cn
本文参考自:http://xn--6rt696i.phpwind.net/blog/htm/do_showone/tid_2872.html

解决办法2(来源:http://www.i170.com/article/5298):打开chm文档的属性,如果该文档是由于上述原因而不能正常打开的,在最下边有一个"安全"选项,说是"此文件来自其它计算机,可能被阻止以帮助保护该计算机."右边有个按钮"解除锁定(K)",用它来解除文档的锁定就可以正常查看了.




//: c8/P17
// a class with non-default constructor.
class P17a {
 private int i;
 P17a(int i1) {
  i = i1;
  System.out.println("P17a created.");
 }
 int geti(){
  return i;
 }
}
// a class whose method return an object
// of a class which with non-default constructor.
class P17b {
 static P17a geta(int i2) {
  return new P17a(i2);
 }
 public static void main(String[] args){
  P17a a = P17b.geta(3);
  System.out.println(a.geti());
 }
}
// an inner class which implements
// a class with non-default constructor.
public class P17 {
 // object accessed by inner class must be declared final:
 P17a geta(final int i3) {
  // just passby the parameter by new statement.
  return new P17a(i3) {
   //cannot initialize like this:
   //super(i3);
   int geti() {
    System.out.println("it's i");
    return i3;
   }
  };
 }
 public static void main(String[] args) {
  P17 p = new P17();
  P17a a = p.geta(3);
  System.out.println(a.geti());
 }
}




    摘要:chapter 8 practice 16 : inner class hidden the implements    (全文共1070字)——点击此处阅读全文




    摘要:TIJ for ASP    (全文共220字)——点击此处阅读全文




    摘要:断网    (全文共221字)——点击此处阅读全文




    摘要:chater 8 practice 15 : implements interface with anonymous inner class    (全文共667字)——点击此处阅读全文




    摘要:chapter 8 practice 14 : implements interface with inner class in scope    (全文共1039字)——点击此处阅读全文



注: 候捷版 thinking in java , the second eddition 这一道课后习题似乎翻译有误.

中文是这样写的:撰写一个interface,令它具备至少一个函数,并在其中某个函数内定义一个inner class用以实现该interface.这个函数必须传回一个reference指向你的那个interface.

英文原文是这样的:Create an interface with at least one method, and implement that interface by defining an inner class within a method, which returns a reference to your interface.

下面我的解是针对英文的理解.

//: chapter 8 / practice 13
// implements interface with inner class in method.

interface Sport {
 void keepHealth();
 void makeStrong();
}

public class P13 {
 Sport getSport() {
  class tableTennis implements Sport {
   public void keepHealth() {
    System.out.println("keepHealth()");
   }
   public void makeStrong() {
    System.out.println("makeStrong()");
   }
  }
  return new tableTennis();
 }
 public static void main(String[] args) {
  P13 p = new P13();
  Sport s = p.getSport();
  s.keepHealth();
 }
}





    摘要:This practice was still remain a doubt: why cannot access protected inner class in inheritanted class?    (全文共1456字)——点击此处阅读全文




    摘要:chapter 8 practice 9 : Multiple interface    (全文共1112字)——点击此处阅读全文




    摘要:chapter 8 practice 8 : change Rodent to be an interface.    (全文共2052字)——点击此处阅读全文




    摘要:chater 8 practice 7 : Multi Interface    (全文共2555字)——点击此处阅读全文




    摘要:在donews上发表html代码.    (全文共98字)——点击此处阅读全文




    摘要:Excel 使用宏解决分类统计。    (全文共2159字)——点击此处阅读全文




    摘要:Excel 分类统计解决办法    (全文共1237字)——点击此处阅读全文