PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/test/org/apache/hadoop/hive/scripts/extracturl.java

#
Java | 58 lines | 29 code | 7 blank | 22 comment | 3 complexity | 6d92d6c552b66ba0d10672af57dc93a5 MD5 | raw file
 1/**
 2 * Licensed to the Apache Software Foundation (ASF) under one
 3 * or more contributor license agreements.  See the NOTICE file
 4 * distributed with this work for additional information
 5 * regarding copyright ownership.  The ASF licenses this file
 6 * to you under the Apache License, Version 2.0 (the
 7 * "License"); you may not use this file except in compliance
 8 * with the License.  You may obtain a copy of the License at
 9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package org.apache.hadoop.hive.scripts;
20
21import java.io.BufferedReader;
22import java.io.InputStreamReader;
23import java.util.regex.Matcher;
24import java.util.regex.Pattern;
25
26/**
27 * extracturl.
28 *
29 */
30public final class extracturl {
31
32  protected static final Pattern pattern = Pattern.compile(
33      "<a href=\"http://([\\w\\d]+\\.html)\">link</a>",
34      Pattern.CASE_INSENSITIVE);
35  static InputStreamReader converter = new InputStreamReader(System.in);
36  static BufferedReader in = new BufferedReader(converter);
37
38  public static void main(String[] args) {
39    String input;
40    try {
41      while ((input = in.readLine()) != null) {
42        Matcher m = pattern.matcher(input);
43
44        while (m.find()) {
45          String url = input.substring(m.start(1), m.end(1));
46          System.out.println(url + "\t" + "1");
47        }
48      }
49    } catch (Exception e) {
50      e.printStackTrace();
51      System.exit(1);
52    }
53  }
54
55  private extracturl() {
56    // prevent instantiation
57  }
58}