可以这样:import java.util.*;
import net.cnnic.kwrrp.*;/**
 * Insert the type's description here.
 * Creation date: (2001-7-29 15:46:44)
 * @author: Administrator
 */
public class TestBed {    /**
     * TestBed constructor comment.
     */
  public TestBed() {
super();
    }
    /**
     * Starts the application.
     * @param args an array of command-line arguments
     */
    public static void main(java.lang.String[] args)
    {
// Insert code to start the application here. RRPCommands rrp = null;
try
{
rrp=new RRPCommands("kwrrp.conf");
}
catch (Exception e)
{
System.out.println("Init error :"+e.getMessage());
return;
}
        
        String[] customers = {"碳酸钙","A钙","B钙","C钙","D钙","E钙"};
        for(int i=0; i<customers.length(); i++){
          testKeyword(rrp, customers[i]);
        }
    }    private static void testKeyword(RRPCommands rrp, String s)
    {
     java.util.Hashtable keyWordAttributes;
        Vector keyWords=new Vector();
        keyWords.add(s);        keyWordAttributes = new java.util.Hashtable();
        keyWordAttributes.put("internal_code", "G");
        keyWordAttributes.put("url", "http://www.cn-wunan.com");
        keyWordAttributes.put("apply_purpose", "客户注册");
        keyWordAttributes.put("unit_cname", "碳酸钙厂");
        keyWordAttributes.put("unit_ename", "tansuangai chang");
        keyWordAttributes.put("unit_py", "tansuangai");
        keyWordAttributes.put("unit_abbr", "tansuangai");
        keyWordAttributes.put("unit_manager", "黄海平");
        keyWordAttributes.put("c_address", "中国");
        keyWordAttributes.put("e_address", "china");
        keyWordAttributes.put("zipcode", "123456");
        keyWordAttributes.put("location", "中国");
        
        try
        {
            rrp.addKeyWord(keyWords,keyWordAttributes);
        }
catch (RRPException e)
        {
                System.out.println("Exception is : " + e.getMessage());
                return;
        }    
}当然你可以对testKeyword(RRPCommands rrp, String s) 加更多的参数来满足不同的keyWordAttributes的需要。

解决方案 »

  1.   

    谢谢,Joeblackyang(最近喜欢玩魔兽)  ,运行后提示:
    C:\jdk1.3\bin>javac TestBed.java
    TestBed.java:37: cannot resolve symbol
    symbol  : method length  ()
    location: class java.lang.String[]
            for(int i=0; i<customers.length(); i++){
                                    ^
    1 errorC:\jdk1.3\bin>请问怎样解决?
      

  2.   

    把customers.length()改成customers.length
      

  3.   

    谢谢lovedandan(工作了~郁闷了~) ,你是OICQ吗,我的是:418424
      

  4.   

    谢谢lovedandan(工作了~郁闷了~) ,你有OICQ吗,我的是:418424