Example #1
0
  /*
  	-- This is a helper methid to run the morph files
  */
  private static void runMorphDataSet() throws Exception {

    String morph_directory =
        "../../thesis-datasets/morph/"; // directory where all the morph code is stored
    File d = new File(morph_directory);
    // get all the files from a directory
    File[] fList = d.listFiles();
    List<String> dir_list = new ArrayList<String>();
    for (File file : fList) {
      if (file.isDirectory()) {
        dir_list.add(file.getName());
      }
    }
    for (String dir : dir_list) {
      directory = morph_directory + dir + "/";
      System.out.println("Running TDDD " + directory);
      ReadFile.readFile(directory, fileList); // read the two files
      System.out.println(fileList.get(0) + " " + fileList.get(1));
      preliminaryStep(directory);
      startCDC();
      fileList.clear();
      fileArray.clear();
      hashed_File_List.clear();
    }
  }
Example #2
0
 public static boolean callCheat(ArrayList<Card> caller) {
   // If the last person cheated
   if (lastPlayerCheated) {
     // gives the person who cheated the card
     lastPlayerHand.addAll(pile);
     pile.clear();
     return true;
   } else {
     // If the last person did not cheat
     // Gives the cards to the caller
     caller.addAll(pile);
     pile.clear();
     return false;
   }
 }
Example #3
0
  // Test the change plan when trying to change a student plan
  @Test
  public void transferpairtest() {
    Backend b = new Backend();
    String[] args = new String[1];
    args[0] = "MasterBankAccounts.txt";

    tlist.clear();

    Transaction t = new Transaction();
    t.setCode("10");
    t.setMisc("A");
    t.setName("");

    Transaction t2 = new Transaction();
    t2.setCode("02");
    t2.setNum("00005");

    Transaction t3 = new Transaction();
    t3.setCode("00");

    tlist.add(t);
    tlist.add(t2);
    tlist.add(t3);

    b.load(args);
    b.setTransactions(tlist);
    b.handletransactions();
    assertEquals("Transfer transactions must come in pairs\n", outContent.toString());
  }
  // Deze method checkt rooster conflicten (Dubbele roosteringen van studenten)
  public int computeStudentConflicts() {
    ArrayList<Student> checkedStudentsList = new ArrayList<Student>();
    int studentConflictCounter = 0;
    boolean conflictFound = false;

    for (int i = 0; i < timeslots; i++) {
      for (int j = 0; j < rooms.size() - 1; j++) {
        Activity activity = rooms.get(j).timetable.get(i);
        if (activity != null) {
          for (Student student : activity.studentGroup) {
            if (!checkedStudentsList.contains(student)) {
              for (int k = j + 1; k < rooms.size(); k++) {
                Room otherRoom = rooms.get(k);
                Activity otherActivity = otherRoom.timetable.get(i);
                if (otherActivity != null) {
                  if (otherActivity.studentGroup.contains(student)) {
                    studentConflictCounter++;
                    conflictFound = true;
                  }
                }
              }
            }
            if (conflictFound) {
              checkedStudentsList.add(student);
              conflictFound = false;
            }
          }
        }
      }
      checkedStudentsList.clear();
    }
    return studentConflictCounter;
  }
Example #5
0
  public void getSavedLocations() {
    // System.out.println("inside getSavedLocations");				//CONSOLE * * * * * * * * * * * * *
    loc.clear(); // clear locations.  helps refresh the list when reprinting all the locations
    BufferedWriter f = null; // just in case file has not been created yet
    BufferedReader br = null;
    try {
      // attempt to open the locations file if it doesn't exist, create it
      f =
          new BufferedWriter(
              new FileWriter("savedLocations.txt", true)); // evaluated true if file does not exist
      br = new BufferedReader(new FileReader("savedLocations.txt"));

      String line; // each line is one index of the list
      loc.add("Saved Locations");
      // loop and read a line from the file as long as we don't get null
      while ((line = br.readLine()) != null)
        // add the read word to the wordList
        loc.add(line);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        // attempt the close the file

        br.close(); // close bufferedwriter
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }
  }
Example #6
0
  public static void main(String args[]) throws IOException, ParseException {
    Options options = new Options();
    options.addOption("u", "uniquehits", false, "only output hits with a single mapping");
    options.addOption(
        "s",
        "nosuboptimal",
        false,
        "do not include hits whose score is not equal to the best score for the read");
    CommandLineParser parser = new GnuParser();
    CommandLine cl = parser.parse(options, args, false);
    boolean uniqueOnly = cl.hasOption("uniquehits");
    boolean filterSubOpt = cl.hasOption("nosuboptimal");

    ArrayList<String[]> lines = new ArrayList<String[]>();

    String line;
    String lastRead = "";
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while ((line = reader.readLine()) != null) {
      String pieces[] = line.split("\t");
      if (!pieces[0].equals(lastRead)) {
        printLines(lines, uniqueOnly, filterSubOpt);
        lines.clear();
      }
      lines.add(pieces);
      lastRead = pieces[0];
    }
    printLines(lines, uniqueOnly, filterSubOpt);
  }
 public HttpReport(QAT parent, String urlString, String baseDir, StatusWindow status) {
   // check if the basedir exists
   if (!(new File(baseDir).exists())) {
     String message = "Error - cannot generate report, directory does not exist:" + baseDir;
     if (status == null) {
       System.out.println(message);
     } else {
       status.setMessage(message);
     }
     return;
   }
   this.parent = parent;
   this.status = status;
   processedLinks = new ArrayList();
   try {
     processURL(new URL(urlString), baseDir, status);
     writeDeadLinks(baseDir);
   } catch (MalformedURLException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     processedLinks.clear();
   }
 }
  public static ArrayList<ArrayList<TaggedWord>> getPhrasesNaive(
      String sentence, LexicalizedParser lp, AbstractSequenceClassifier<CoreLabel> classifier) {
    ArrayList<ArrayList<TaggedWord>> newList = new ArrayList<ArrayList<TaggedWord>>();
    ArrayList<TaggedWord> taggedWords = StanfordNER.parse(sentence, lp, classifier);
    HashMap<String, String> phraseBoundaries = new HashMap<String, String>();
    phraseBoundaries.put(",", ",");
    phraseBoundaries.put("\"", "\"");
    phraseBoundaries.put("''", "''");
    phraseBoundaries.put("``", "``");
    phraseBoundaries.put("--", "--");
    // List<Tree> leaves = parse.getLeaves();
    ArrayList<TaggedWord> temp = new ArrayList<TaggedWord>();
    int index = 0;
    while (index < taggedWords.size()) {
      if ((phraseBoundaries.containsKey(taggedWords.get(index).word()))) {
        if (temp.size() > 0) {
          // System.out.println(temp);
          ArrayList<TaggedWord> tempCopy = new ArrayList<TaggedWord>(temp);
          newList.add(Preprocess(tempCopy));
        }
        temp.clear();
      } else {
        // System.out.println(taggedWords.get(index).toString());
        temp.add(taggedWords.get(index));
      }
      index += 1;
    }
    if (temp.size() > 0) {
      ArrayList<TaggedWord> tempCopy = new ArrayList<TaggedWord>(temp);
      newList.add(Preprocess(tempCopy));
    }

    // System.out.println(newList);
    return newList;
  }
 public boolean comparePrefix(String prefixCode, String prefixCodeWithProc) {
   try {
     boolean flag = false;
     String prefixBreak[] = prefixCode.split("#");
     String prefixProcBreak[] = prefixCodeWithProc.split("#");
     for (String str : prefixBreak) {
       flag = false;
       for (int i = 0; i < prefixProcBreak.length; i++) {
         if (prefixProcBreak[i].equals(str)) {
           flag = true;
           prefixProcBreak[i] = "-1";
           break;
         }
       }
       if (!flag) return false;
     }
     if (prefixCode.length() == prefixCodeWithProc.length()) {
       procList.clear();
       procList.add(prefixCodeWithProc);
       return true;
     } else procList.add(prefixCodeWithProc);
   } catch (Exception ed) {
   }
   return false;
 }
Example #10
0
  private void readMetaData() throws IOException {

    BufferedReader br =
        new BufferedReader(
            new InputStreamReader(new ByteArrayInputStream(this.metadata.toByteArray())));
    String strLine;

    String entryDefinition = "Entry-Definitions:";
    String image = "image:";

    imageNames.clear();

    while ((strLine = br.readLine()) != null) {

      if (strLine.contains(entryDefinition)) {
        this.entryDefinitions =
            strLine.substring(entryDefinition.length(), strLine.length()).trim();
      }
      if (strLine.contains(image)) {
        this.imageNames.add(strLine.substring(image.length(), strLine.length()).trim());
      }
    }

    br.close();
  }
Example #11
0
  private String findSynonym(ArrayList<Word> sentence, int indexToReplace /*<Word wordIn>*/) {
    /**
     * Takes in one String of a word, hopefully only one word(will truncate after space), and
     * searches for a suitable synonym
     *
     * <p>*
     */
    String output = "";
    // String word;
    // word=wordIn.getString();
    String word = sentence.get(indexToReplace).getValue();
    Synset[] synsets = database.getSynsets(word);

    synonyms.clear();

    if (synsets.length > 0) {

      for (int i = 0; i < synsets.length; i++) {

        String[] wordForms = synsets[i].getWordForms();
        for (int j = 0; j < wordForms.length; j++) {
          if (wordForms[j].contains(" ")) {
            System.out.println(wordForms[j]);
          } else if (!wordForms[j].equals(word)) synonyms.add(wordForms[j]);
        }
      }

      // FIND IF PLURAL OR NO HERE

      /////////////////////////// ###########################////////////////////

      Collections.sort(synonyms, myLengthComparator);
      // synonyms is now sorted as longest first

      // now we have a list of all the terms that can replace the word.
      // We need to check them in the lexical analyzer
      //			System.out.println("kkkk");
      if (synonyms.size() == 0) return word;
      while (!LexicalAnalyzer(sentence, indexToReplace, synonyms.get(0))) {
        //			System.out.println("1");
        synonyms.remove(0);
        if (synonyms.size() == 0) return word; // did not find synonym

        if (synonyms.get(0).length() <= word.length()) {
          return word;
          // do not replace word, synonyms are shorter
        }
      }

      ////////////// ############# PLACEHOLDER CODE
      if (synonyms.size() > 0) output = synonyms.get(0);
      else output = word;
      ///////////// ################# PLACEHOLDER CODE
    } else { // There are no other known synonyms in our wordnet database.
      output = word;
    }

    return output;
  }
 /**
  * Remove the modules (that were previously registered by start()) from the reload monitor thread.
  *
  * <p>This method is invoked be WebContainer.stop() only when dynamic reloading has been enabled
  * in server.xml.
  */
 public void stop() {
   ReloadMonitor reloadMonitor = ReloadMonitor.getInstance(1);
   for (int i = 0; i < _reloadables.size(); i++) {
     String id = (String) _reloadables.get(i);
     reloadMonitor.removeMonitoredEntry(id);
   }
   _reloadables.clear();
   _reloadables = null;
 }
Example #13
0
  public void parseString(String fileName) {
    String text = readFromFile(fileName);
    String[] textInMass = text.split(" ");
    ArrayList<String> additionalList = new ArrayList<String>();
    Map<String, List<String>> someMap = new HashMap();

    for (int i = 0; i < textInMass.length; i++) {
      textInMass[i] = replaceWord(textInMass[i]);
    }

    try {
      if (text == null) {
        throw new NullPointerException();
      } else {
        for (String word : textInMass) {
          if (someMap.containsKey(word)) {
            additionalList = (ArrayList<String>) someMap.get(word);
            additionalList.add(word);
            someMap.remove(word);
            someMap.put(word, new ArrayList<String>(additionalList));
            additionalList.clear();
          } else {
            additionalList.add(word);
            someMap.put(word, new ArrayList<String>(additionalList));
            additionalList.clear();
          }
        }
      }
    } catch (NullPointerException e) {
      log.error("The String is empty");
    }

    try {
      for (String key : someMap.keySet()) {
        String ss = key + " ";
        for (int i = 0; i < someMap.get(key).size(); i++) {
          ss = ss + "*";
        }
        log.info(ss);
      }
    } catch (Exception e) {
      log.error("An error occurred after the change. error={}", e);
    }
  }
 /**
  * Returns a list of blocks that have timed out their replication requests. Returns null if no
  * blocks have timed out.
  */
 Block[] getTimedOutBlocks() {
   synchronized (timedOutItems) {
     if (timedOutItems.size() <= 0) {
       return null;
     }
     Block[] blockList = timedOutItems.toArray(new Block[timedOutItems.size()]);
     timedOutItems.clear();
     return blockList;
   }
 }
 /**
  * Set the classpath to a given list of libdirs.
  *
  * @param libdirList is an arraylist of File objects, each representing a directory.
  */
 public synchronized void setClassPath(ArrayList libdirList) throws ManifoldCFException {
   if (currentClasspath.size() > 0) {
     currentClasspath.clear();
     classLoader = null;
   }
   int i = 0;
   while (i < libdirList.size()) {
     File dir = (File) libdirList.get(i++);
     addToClassPath(dir, null);
   }
 }
Example #16
0
  /**
   * Update local information from the scene. It's important that this method is synchronized
   * because we get ConcurrentModificationException's during rendering otherwise.
   *
   * <p>This method is called from sceneChanged().
   */
  protected synchronized void updateCharges(Scene theScene) {
    // Clear cached infos.
    cachedBounds = null;
    cachedWire = null;
    charges.clear();

    setPositive = null;
    setNegative = null;

    // Get all selection sets.
    Object layersObj = theScene.getMetadata("selectionsPlugin.selectionSets");

    if (layersObj == null) return;

    if (!(layersObj instanceof ArrayList)) return;

    ArrayList<ObjectSet> layers = (ArrayList<ObjectSet>) layersObj;

    // Try to find those which are of interest for us.
    for (ObjectSet set : layers) {
      if (set.getName().equals(setNamePositive)) {
        setPositive = set;
      } else if (set.getName().equals(setNameNegative)) {
        setNegative = set;
      }
    }

    // Create charges.
    if (setPositive != null) {
      for (ObjectInfo oi : setPositive.getObjects(theScene)) {
        if (oi.getObject() instanceof Sphere) {
          Sphere s = (Sphere) oi.getObject();
          double q = s.getRadii().x;
          Vec3 pos = oi.getCoords().getOrigin();

          charges.add(new SphereCharge(pos, q));
        }
      }
    }

    if (setNegative != null) {
      for (ObjectInfo oi : setNegative.getObjects(theScene)) {
        if (oi.getObject() instanceof Sphere) {
          Sphere s = (Sphere) oi.getObject();
          double q = -s.getRadii().x;
          Vec3 pos = oi.getCoords().getOrigin();

          charges.add(new SphereCharge(pos, q));
        }
      }
    }
  }
Example #17
0
  public void getIndexInfo(String indexdir, int freqThreshold) {
    IndexReader reader = null;

    try {
      Directory dir = FSDirectory.open(new File(indexdir));
      System.out.println(dir);
      reader = IndexReader.open(dir);

      System.out.println("document num:" + reader.numDocs());
      System.out.println("======================");

      TermEnum terms = reader.terms();
      sortedTermQueue.clear();
      maxDocNum = reader.maxDoc();
      linkMap.clear();
      termList.clear();
      while (terms.next()) {
        // System.out.print(terms.term() + "\tDocFreq:" +
        TermDocs termDocs = reader.termDocs(terms.term());
        MyTerm temp = new MyTerm(terms.term(), termDocs, maxDocNum);
        if (temp.totalFreq < freqThreshold) {
          continue;
        } /*
           * if(temp.originTrem.text().length()==1){ continue; }
           */
        linkMap.put(temp.originTrem.text(), temp);
        sortedTermQueue.add(temp);
        termList.add(temp);
      }
      System.out.println("total Size:" + sortedTermQueue.size());
      System.out.println("mapsize:" + linkMap.keySet().size());
      // System.exit(0);
      int num = 0;
      this.maxFreq = sortedTermQueue.peek().totalFreq;
      while (!sortedTermQueue.isEmpty()) {
        num++;
        System.out.println(num + ":" + sortedTermQueue.poll());
      }
      System.out.println("read index info done");
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        reader.close();

      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Example #18
0
File: Gen.java Project: hrnn/olymp
  static void print() throws IOException {
    done++;
    System.err.println(done);
    PrintWriter out;
    if (done < 10) out = new PrintWriter("../tests/0" + String.valueOf(done));
    else out = new PrintWriter("../tests/" + String.valueOf(done));

    out.println(data.size());
    for (int i = 0; i < data.size(); i++) {
      out.println(data.get(i));
    }
    data.clear();
    out.close();
  }
Example #19
0
  void addNewConnections() {
    ListIterator<EventableSocketChannel> iter = DetachedConnections.listIterator(0);
    while (iter.hasNext()) {
      EventableSocketChannel ec = iter.next();
      ec.cleanup();
    }
    DetachedConnections.clear();

    ListIterator<Long> iter2 = NewConnections.listIterator(0);
    while (iter2.hasNext()) {
      long b = iter2.next();

      EventableChannel ec = Connections.get(b);
      if (ec != null) {
        try {
          ec.register();
        } catch (ClosedChannelException e) {
          UnboundConnections.add(ec.getBinding());
        }
      }
    }
    NewConnections.clear();
  }
Example #20
0
  /**
   * Makes a stair step heat map from an array of windows in bar format. One per chromosome. Don't
   * forget to set the barDirectory and score Index!!!!!!!
   */
  public void makeStairStepBarFiles() {
    // make bar parser
    BarParser bp = new BarParser();
    bp.setZipCompress(true);
    HashMap<String, String> tagVals = new HashMap<String, String>();
    tagVals.put(BarParser.GRAPH_TYPE_TAG, BarParser.GRAPH_TYPE_STAIRSTEP);
    tagVals.put(BarParser.GRAPH_TYPE_COLOR_TAG, "#FF00FF"); // fusha
    tagVals.put(BarParser.SOURCE_TAG, bedFile.toString());

    // for each chromosome
    System.out.print("Printing... ");
    Iterator<String> it = bedLinesHash.keySet().iterator();
    while (it.hasNext()) {
      chromosome = it.next();
      System.out.print(chromosome + " ");
      windows = bedLinesHash.get(chromosome);
      // add blocks
      assembleBlocks();
      // balance by adding max or min at zero base
      balanceValues();
      // write bar file
      File barFile = new File(barDirectory, chromosome + ".bar");
      bp.writeBarFile(
          barFile,
          chromosome,
          genomeVersion,
          '.',
          Num.arrayListOfIntegerToInts(bases),
          Num.arrayListOfFloatToArray(values),
          tagVals);
      // clear ArrayLists
      bases.clear();
      values.clear();
    }
    System.out.println();
  }
Example #21
0
  void close() {
    try {
      if (mySelector != null) mySelector.close();
    } catch (IOException e) {
    }
    mySelector = null;

    // run down open connections and sockets.
    Iterator<ServerSocketChannel> i = Acceptors.values().iterator();
    while (i.hasNext()) {
      try {
        i.next().close();
      } catch (IOException e) {
      }
    }

    // 29Sep09: We create an ArrayList of the existing connections, then iterate over
    // that to call unbind on them. This is because an unbind can trigger a reconnect,
    // which will add to the Connections HashMap, causing a ConcurrentModificationException.
    // XXX: The correct behavior here would be to latch the various reactor methods to return
    // immediately if the reactor is shutting down.
    ArrayList<EventableChannel> conns = new ArrayList<EventableChannel>();
    Iterator<EventableChannel> i2 = Connections.values().iterator();
    while (i2.hasNext()) {
      EventableChannel ec = i2.next();
      if (ec != null) {
        conns.add(ec);
      }
    }
    Connections.clear();

    ListIterator<EventableChannel> i3 = conns.listIterator(0);
    while (i3.hasNext()) {
      EventableChannel ec = i3.next();
      eventCallback(ec.getBinding(), EM_CONNECTION_UNBOUND, null);
      ec.close();

      EventableSocketChannel sc = (EventableSocketChannel) ec;
      if (sc != null && sc.isAttached()) DetachedConnections.add(sc);
    }

    ListIterator<EventableSocketChannel> i4 = DetachedConnections.listIterator(0);
    while (i4.hasNext()) {
      EventableSocketChannel ec = i4.next();
      ec.cleanup();
    }
    DetachedConnections.clear();
  }
Example #22
0
  void removeUnboundConnections() {
    ListIterator<Long> iter = UnboundConnections.listIterator(0);
    while (iter.hasNext()) {
      long b = iter.next();

      EventableChannel ec = Connections.remove(b);
      if (ec != null) {
        eventCallback(b, EM_CONNECTION_UNBOUND, null);
        ec.close();

        EventableSocketChannel sc = (EventableSocketChannel) ec;
        if (sc != null && sc.isAttached()) DetachedConnections.add(sc);
      }
    }
    UnboundConnections.clear();
  }
 public static ArrayList<String> validateSamplesDirectoryStructureIdentifyVersions(
     String samplesDirPath, ArrayList<String> versionArr) {
   String samplesDir[] = getDirectoryNames(samplesDirPath);
   StringBuilder builder = new StringBuilder();
   ArrayList<String> tempArr = new ArrayList<String>();
   Pattern numeric = Pattern.compile("[0-9_.-]");
   for (String dir : samplesDir) {
     for (int item = dir.length() - 1; item >= 0; item--) {
       char singleChar = dir.charAt(item);
       Matcher matcher = numeric.matcher(Character.toString(singleChar));
       // Find all matches
       if (matcher.find()) {
         // Get the matching string
         builder.append(singleChar);
       } else {
         if (builder.length() > 1) {
           tempArr.add(builder.toString());
           builder.setLength(0);
         } else {
           builder.setLength(0);
         }
       }
       if (item == 0 && builder.length() != 0) {
         tempArr.add(builder.toString());
         builder.setLength(0);
       }
     }
     int max;
     int previousMax = 0;
     String[] version = new String[1];
     for (String element : tempArr) {
       max = element.length();
       if (max > previousMax) {
         previousMax = max;
         version[0] = element;
       }
     }
     if (version[0] != null) {
       if (version[0].length() >= 2) {
         versionArr.add(dir);
       }
     }
     tempArr.clear();
   }
   return versionArr;
 }
Example #24
0
  /** If a key is pressed perform the respective actions */
  public void keyPressed() {

    // Add 'stems' to the balls
    if (keyCode == SHIFT) {
      stems = !stems;
      for (int i = 0; i < balls.size(); i++) {
        Ball b = (Ball) balls.get(i);
        b.STEM = stems;
      }
    }
    // toggle repaint background
    else if (key == 'b') REPAINT = !REPAINT;
    // Empty the ArrayList of Balls
    else if (key == 'x') balls.clear();
    // Add a ball
    else if (key == 'f') addBall();
  }
Example #25
0
 public void run() {
   ArrayList<Pair> mergeArray;
   if (id % 2 == 0) {
     mergeArray = ans;
   } else {
     mergeArray = ans2;
   }
   synchronized (mergeArray) {
     ArrayList<Pair> tempArray = new ArrayList<Pair>();
     int idArray = 0;
     int indexAns = 0;
     while (idArray < array.size() && indexAns < mergeArray.size()) {
       if (isI) {
         if (new ComparatorLower().compare(array.get(idArray), mergeArray.get(indexAns)) < 0) {
           tempArray.add(array.get(idArray));
           idArray++;
         } else {
           tempArray.add(mergeArray.get(indexAns));
           indexAns++;
         }
       } else {
         if (new ComparatorNotLower().compare(array.get(idArray), mergeArray.get(indexAns))
             < 0) {
           tempArray.add(array.get(idArray));
           idArray++;
         } else {
           tempArray.add(mergeArray.get(indexAns));
           indexAns++;
         }
       }
     }
     while (idArray < array.size()) {
       tempArray.add(array.get(idArray));
       idArray++;
     }
     while (indexAns < mergeArray.size()) {
       tempArray.add(mergeArray.get(indexAns));
       indexAns++;
     }
     mergeArray.clear();
     for (int i = 0; i < tempArray.size(); i++) {
       mergeArray.add(tempArray.get(i));
     }
   }
 }
Example #26
0
 public String getAddress() {
   while (hostList.size() == 0) {
     try {
       sleep(100);
     } catch (InterruptedException e) {
     }
   }
   String name = "";
   String temp = "";
   for (int x = 0; x < hostList.size(); x++) {
     name = ((String) hostList.get(x));
     if (name.substring(0, userName.length()).equals(userName)) {
       temp = ((String) hostList.get(x)).substring(userName.length() + 1);
     }
   }
   temp = temp.substring(0, temp.indexOf(":"));
   updated = true;
   hostList.clear();
   return temp.replace('.', ',');
 }
  private void getServersFile() throws Exception {
    InputStream is = this.getClass().getResourceAsStream("/servers");
    if (is == null) throw new IOException("Cannot find servers file");

    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    configuredServers.clear();
    String line;
    while ((line = br.readLine()) != null) {
      configuredServers.add(line);
    }

    Collections.sort(configuredServers);

    if (configuredServers.size() < 1) throw new IOException("No entries found in servers file");

    int lnum = 1;
    for (int i = 0; i < configuredServers.size(); i++) {
      LOG.debug("servers file line " + lnum + " [" + configuredServers.get(i) + "]");
      lnum++;
    }
  }
Example #28
0
  public void load(String filename) {
    try {
      internalFilename = filename;

      FileInputStream inputStream = new FileInputStream(filename);
      InputStreamReader reader = new InputStreamReader(inputStream, "UTF-8");

      Scanner scanner = new Scanner(reader);

      String data = "";
      internalList.clear();
      while (scanner.hasNextLine()) {
        data = scanner.nextLine();

        internalList.add(data);
      }

      Kikkit.MinecraftLog.info("Whitelist Loaded from " + filename);
    } catch (Exception f) {
      Kikkit.MinecraftLog.warning("Could not load the whitelist file: " + filename);
    } finally {
    }
  }
Example #29
0
 public void closeNetworking() {
   for (FixedTimer timer : timers) timer.stop();
   timers.clear();
   if (Global.connectingSocket != null) {
     try {
       Global.connectingSocket.close();
     } catch (IOException ex) {
     }
   }
   closeClient(mainServer);
   closeClient(bulletStream);
   closeClient(powerStream);
   closeClient(turretStream);
   closeClient(powerRemover);
   closeClient(chatLog);
   closeClient(fadeLog);
   closeClient(serverTime);
   if (playerByteStreams != null) {
     for (int i = 0; i < playerByteStreams.length; ++i) {
       closeClient(playerByteStreams[i]);
     }
   }
 }
  private void readChoices(IXMLElement element, ArrayList<String> choiceList) {
    List<IXMLElement> choices = element.getChildrenNamed("choice");

    if (choices == null) {
      return;
    }

    choiceList.clear();

    for (IXMLElement choice : choices) {
      String value = choice.getAttribute("value");

      if (value != null) {
        List<OsModel> osconstraints = OsConstraintHelper.getOsList(choice);

        if (OsConstraintHelper.oneMatchesCurrentSystem(osconstraints)) {
          if (value.equalsIgnoreCase(ECLIPSE_COMPILER_NAME)) {
            // check for availability of eclipse compiler
            try {
              Class.forName(ECLIPSE_COMPILER_CLASS);
              choiceList.add(value);
            } catch (ExceptionInInitializerError eiie) {
              // ignore, just don't add it as a choice
            } catch (ClassNotFoundException cnfe) {
              // ignore, just don't add it as a choice
            }
          } else {
            try {
              choiceList.add(this.vs.substitute(value, SubstitutionType.TYPE_PLAIN));
            } catch (Exception e) {
              // ignore, just don't add it as a choice
            }
          }
        }
      }
    }
  }