addurltocollection.java

来自「关于Ultraseek的一些用法,刚初学,所以都是比较简单」· Java 代码 · 共 69 行

JAVA
69
字号
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- * *  $RCSFile$ $Revision: 1.18 $ $Date: 2006/02/01 00:17:24 $ * *  Copyright (c) 2000-2002 Autonomy Corp.  All Rights Reserved. * * */import java.io.BufferedReader;import java.io.InputStreamReader;import java.net.URL;import com.ultraseek.xpa.server.UltraseekServer;import com.ultraseek.xpa.server.UltraseekCollection;import com.ultraseek.xpa.server.ScannerCollection;import com.ultraseek.xpa.server.SpiderCollection;/** *  A simple demo application that adds URLs  *  to an Ultraseek collection. */public class AddURLToCollection {  AddURLToCollection() { }  public static void main(String[] args) throws Exception {    InputStreamReader inputStreamReader = new InputStreamReader(System.in);    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);    System.out.println();    System.out.println("This is a simple demo application that adds URLs");    System.out.println("to an Ultraseek collection.");    System.out.println();    System.out.println("Enter the hostname and TCP port of your");    System.out.println("running Ultraseek instance.");    System.out.print("hostname: ");    String host = bufferedReader.readLine();    System.out.print("TCP port: ");    int port = Integer.parseInt(bufferedReader.readLine());    UltraseekServer server = new UltraseekServer(host,port);    System.out.println();    System.out.println("Here is the UltraseekServer object:");    System.out.println(server);    System.out.println("Enter the internal name of the collection.");    System.out.print("collection: ");    String id = bufferedReader.readLine();    UltraseekCollection collection =       (UltraseekCollection)server.getSearchCollection(id);    System.out.println();    System.out.println("Here is the UltraseekCollection object:");    System.out.println(collection);    for (;;) {      System.out.println();      System.out.println("Enter a URL to add.");      System.out.print("URL: ");      String line = bufferedReader.readLine();      if (line==null) break;      URL url = new URL(line);      if (collection instanceof SpiderCollection) {        ((SpiderCollection)collection).addURL(url);      } else if (collection instanceof ScannerCollection) {        ((ScannerCollection)collection).addURL(url);      } else {        System.out.println("Can't addURL on that kind of collection.");        continue;      }      System.out.println("Done.");    }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?