コード例 #1
0
  private static void agregaHashEquipasTenis(File ficheiro_global, String hashequipas_tenis)
      throws IOException {
    // TODO Auto-generated method stub
    String s_final = null;
    FileReader fr = new FileReader(ficheiro_global);
    char[] creader = new char[(int) ficheiro_global.length()];
    fr.read(creader);
    s_final = new String(creader);
    Pattern pattern = Pattern.compile(hashequipas_tenis);
    Matcher matcher = pattern.matcher(s_final);

    boolean enc_padrao = false;

    // vector com as ocorrências dos padrões das hashtags de equipas de ténis
    Vector<String> vec_string = new Vector<String>();

    while (matcher.find()) {
      //			System.out.println("I found the text: " + matcher.group());
      //			System.out.println("Inicial index: " + matcher.start());
      //			System.out.println("Inicial index: " + matcher.end());
      vec_string.add(matcher.group());
      enc_padrao = true;
    }

    // se existem padrões relativos a ténis ele gere (insere e remove) as hashtags associadas a
    // essas equipas
    if (enc_padrao) VerificaHashEquipasAppM.recolheDadosHashEquipa(vec_string);

    // caso contrário confirma que não ficaram na bd hashtags de equipas que o utilizador já não
    // quer ver
    else HashEquipa.eliminaHashEquipaMod("Ténis");
  }