Example #1
1
  // ---------------------------------------------------------------------------
  private void printDependencies() throws TablesawException {
    m_printedDependencies = new HashSet<String>();

    try {
      PrintWriter pw = new PrintWriter(new FileWriter("dependency.txt"));

      pw.println("Targets marked with a * have already been printed");
      // Create a reduced set of stuff to print
      Set<String> ruleNames = new HashSet<String>();

      for (String name : m_nameRuleMap.keySet()) ruleNames.add(name);

      for (String name : m_nameRuleMap.keySet()) {
        Rule rule = m_nameRuleMap.get(name);
        for (String dep : rule.getDependNames()) ruleNames.remove(dep);

        for (Rule dep : rule.getDependRules()) {
          if (dep.getName() != null) ruleNames.remove(dep.getName());
        }
      }

      for (String name : ruleNames) {
        if (!name.startsWith(NAMED_RULE_PREFIX)) printDependencies(name, pw, 0);
      }

      pw.close();
    } catch (IOException ioe) {
      throw new TablesawException("Cannot write to file dependency.txt", -1);
    }
  }
 /**
  * This is for debug only: print out training matrices in a CSV type format so that the matrices
  * can be examined in a spreadsheet program for debugging purposes.
  */
 private void WriteCSVfile(
     List<String> rowNames, List<String> colNames, float[][] buf, String fileName) {
   p("tagList.size()=" + tagList.size());
   try {
     FileWriter fw = new FileWriter(fileName + ".txt");
     PrintWriter bw = new PrintWriter(new BufferedWriter(fw));
     // write the first title row:
     StringBuffer sb = new StringBuffer(500);
     for (int i = 0, size = colNames.size(); i < size; i++) {
       sb.append("," + colNames.get(i));
     }
     bw.println(sb.toString());
     // loop on remaining rows:
     for (int i = 0, size = buf.length; i < size; i++) {
       sb.delete(0, sb.length());
       sb.append(rowNames.get(i));
       for (int j = 0, size2 = buf[i].length; j < size2; j++) {
         sb.append("," + buf[i][j]);
       }
       bw.println(sb.toString());
     }
     bw.close();
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
 }
 public String getAnswers(List<IN> l, OutputStyle outputStyle, boolean preserveSpacing) {
   StringWriter sw = new StringWriter();
   PrintWriter pw = new PrintWriter(sw);
   printAnswers(l, pw, outputStyle, preserveSpacing);
   pw.flush();
   return sw.toString();
 }
Example #4
0
 private void writeOption(String optionName, int argument) {
   if (argument != 1) {
     writer.print(optionName);
     writer.print(' ');
     writer.println(argument);
   }
 }
Example #5
0
  public static void main(String[] args) throws IOException {
    input.init(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = input.nextInt(), k = input.nextInt();
    int[] data = new int[n];
    for (int i = 0; i < n; i++) data[i] = input.nextInt();
    int res = 0;
    for (int i = 0; i < k; i++) {
      HashSet<Integer> set = new HashSet<Integer>();
      for (int j = i; j < n; j += k) set.add(data[j]);
      int max = 1;
      for (int x : set) {
        int count = 0;
        for (int j = i; j < n; j += k) {
          if (data[j] == x) count++;
        }
        max = Math.max(max, count);
      }
      res += (n / k) - max;
    }
    out.println(res);

    out.close();
  }
Example #6
0
  // ---------------------------------------------------------------------------
  private void printDependencies(String target, PrintWriter pw, int spacing)
      throws TablesawException {
    Rule tr = findTargetRule(target);
    String[] pre;

    for (int I = 0; I < spacing; I++) pw.print("\t");

    List<String> targetList = new ArrayList<String>();
    if (tr != null) {
      for (String name : tr.getDependNames()) {
        targetList.add(name);
      }

      for (Rule r : tr.getDependRules()) {
        if ((r.getName() != null) && (!r.getName().startsWith(NAMED_RULE_PREFIX))) {
          targetList.add(r.getName());
        } else {
          for (String t : r.getTargets()) {
            targetList.add(t);
          }
        }
      }
    }

    if (!m_printedDependencies.add(target) && (targetList.size() != 0)) {
      pw.println(target + "*");
      return;
    }

    pw.println(target);

    for (String t : targetList) printDependencies(t, pw, spacing + 1);
  }
  public static void reconstructHeaders(Iterable<NativeLibrary> libraries, PrintWriter out) {
    List<MemberRef> orphanMembers = new ArrayList<MemberRef>();
    Map<TypeRef, List<MemberRef>> membersByClass = new HashMap<TypeRef, List<MemberRef>>();
    for (NativeLibrary library : libraries) {
      for (Symbol symbol : library.getSymbols()) {
        MemberRef mr = symbol.getParsedRef();
        if (mr == null) continue;

        TypeRef et = mr.getEnclosingType();
        if (et == null) orphanMembers.add(mr);
        else {
          List<MemberRef> mrs = membersByClass.get(et);
          if (mrs == null) membersByClass.put(et, mrs = new ArrayList<MemberRef>());
          mrs.add(mr);
        }
      }
    }
    for (TypeRef tr : membersByClass.keySet()) out.println("class " + tr + ";");

    for (MemberRef mr : orphanMembers) out.println(mr + ";");

    for (Map.Entry<TypeRef, List<MemberRef>> e : membersByClass.entrySet()) {
      TypeRef tr = e.getKey();
      List<MemberRef> mrs = e.getValue();
      out.println("class " + tr + " \n{");
      for (MemberRef mr : mrs) {
        out.println("\t" + mr + ";");
      }
      out.println("}");
    }
  }
Example #8
0
 public static void addToPlaylist(File[] filesnames) throws Exception {
   if (logger.isDebugEnabled()) logger.debug("Add to playlist (with parameters - filenames[]).");
   File f = new File(Lecteur.CURRENTPLAYLIST.NAME);
   File Fe =
       new File(
           Lecteur.CURRENTPLAYLIST.NAME.substring(0, Lecteur.CURRENTPLAYLIST.NAME.length() - 19)
               + "wssederdferdtdfdgetrdfdte.pl");
   PrintWriter br = new PrintWriter(new BufferedWriter(new FileWriter(Fe)));
   BufferedReader br1 = new BufferedReader(new FileReader(f));
   String st = null;
   while ((st = br1.readLine()) != null) {
     br.println(st);
   }
   for (int i = 0; i < filesnames.length - 1; i++) {
     br.println(filesnames[i].toString());
   }
   br.print(filesnames[filesnames.length - 1].toString());
   br.close();
   br1.close();
   new File(Lecteur.CURRENTPLAYLIST.NAME).delete();
   (new File(
           Lecteur.CURRENTPLAYLIST.NAME.substring(0, Lecteur.CURRENTPLAYLIST.NAME.length() - 19)
               + "wssederdferdtdfdgetrdfdte.pl"))
       .renameTo(new File(Lecteur.CURRENTPLAYLIST.NAME));
 }
  static void eliminarLugarFicheroLOC(Lugar lugar) {
    String fichero = lugar.getFicheroLOC();

    try {
      FileReader fr = new FileReader(fichero);
      BufferedReader br = new BufferedReader(fr);

      String linea;
      ArrayList lineas = new ArrayList();

      do {
        linea = br.readLine();
        if (linea != null) {
          if (!linea.substring(0, lugar.nombre.length()).equals(lugar.nombre)) lineas.add(linea);
        } else break;
      } while (true);
      br.close();
      fr.close();

      FileOutputStream fos = new FileOutputStream(fichero);
      PrintWriter pw = new PrintWriter(fos);

      for (int i = 0; i < lineas.size(); i++) pw.println((String) lineas.get(i));
      pw.flush();
      pw.close();
      fos.close();

    } catch (FileNotFoundException e) {
      System.err.println("error: eliminando " + e);

    } catch (IOException e) {
      System.err.println("error: eliminando 2 : " + e);
    }
  }
Example #10
0
  void run() {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt(), q = in.nextInt();
    int[] v = new int[n], c = new int[n];
    for (int i = 0; i < n; ++i) v[i] = in.nextInt();
    for (int i = 0; i < n; ++i) c[i] = in.nextInt();

    for (int i = 0; i < q; ++i) {
      int a = in.nextInt(), b = in.nextInt();
      long[] dp = new long[n + 1];
      Node[] heap = new Node[2];
      Arrays.fill(dp, -INF);
      for (int j = 0; j < 2; ++j) heap[j] = new Node(-INF, -1);
      for (int j = 0; j < n; ++j) {
        long val = v[j], maxv = val * b;
        int color = c[j];
        maxv = Math.max(dp[color] + val * a, maxv);
        maxv = Math.max(choose(heap, color) + val * b, maxv);
        dp[color] = Math.max(maxv, dp[color]);
        update(heap, dp[color], color);
      }

      long ret = 0;
      for (int j = 1; j <= n; ++j) ret = Math.max(ret, dp[j]);
      out.println(ret);
    }

    out.close();
  }
  public static void main(String[] args) throws IOException {
    StreamsPerfTest perfTest = new StreamsPerfTest();
    PrintWriter console = new PrintWriter(System.out, true);

    print("temp file:" + TEMP_FILE_NAME);
    print("initial file contains " + FILE_CONTENT.length() + " characters");
    print("initial file contains " + FILE_CONTENT_LIST.size() + " rows");
    print("-------------------------------------------");

    String formatPattern = "%1$30s : %2$-10.4f s\n";
    print("1. test 10 attempts:");
    for (StreamTester tester : TESTERS)
      console.printf(formatPattern, tester.getName(), perfTest.test(tester, 10));
    print("-------------------------------------------");

    print("2. test 100 attempts:");
    for (StreamTester tester : TESTERS)
      console.printf(formatPattern, tester.getName(), perfTest.test(tester, 100));
    print("-------------------------------------------");

    print("3. test 200 attempts:");
    for (StreamTester tester : TESTERS)
      console.printf(formatPattern, tester.getName(), perfTest.test(tester, 200));
    print("-------------------------------------------");
  }
Example #12
0
 public void writeFoundWordsFile() throws IOException {
   PrintWriter pw = new PrintWriter(new FileWriter("src\\LW_5\\output2.txt"));
   for (Map.Entry entry : wordsNumStr.entrySet()) {
     pw.println("Word : " + entry.getKey() + ", String number : " + entry.getValue());
   }
   pw.close();
 }
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    res.setContentType("text/html");
    try {
      PrintWriter pw = res.getWriter();
      pw.println("<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE></head>");
      pw.println(
          "<body><br><br><br><form name=modifyuser method=post action='http://peers:8080/servlet/showUser')");
      v = U.allUsers();
      pw.println("<table align='center' border=0> <tr><td>");
      pw.println(
          "Select User Name To Modify</td><td><SELECT id=select1 name=uid style='HEIGHT: 22px; LEFT: 74px; TOP: 222px; WIDTH: 155px'>");
      pw.println("<OPTION selected value=''></OPTION>");
      for (i = 0; i < v.size(); i++)
        pw.println(
            "<OPTION value="
                + (String) v.elementAt(i)
                + ">"
                + (String) v.elementAt(i)
                + "</OPTION>");
      pw.println(
          "</SELECT></td></tr><tr><td></td><td><input type='submit' name='submit' value='Submit'></td></tr></table></form></body></html>");
      pw.flush();
      pw.close();

    } catch (Exception e) {
    }
  }
Example #14
0
 public void writeFile() throws IOException {
   PrintWriter pw = new PrintWriter(new File("src\\LW_5\\output1.txt"));
   for (String item : tags) {
     pw.println(item);
   }
   pw.close();
 }
Example #15
0
  private static void getTopDocuments(int num, HashMap<String, Float> scoremap, String filename)
      throws FileNotFoundException {
    PrintWriter out = new PrintWriter(filename);
    Iterator<String> itr = scoremap.keySet().iterator();
    ArrayList<String> urls = new ArrayList<String>();
    ArrayList<Float> scores = new ArrayList<Float>();

    while (itr.hasNext()) {
      String key = itr.next();
      if (scores.size() < num) {
        scores.add(scoremap.get(key));
        urls.add(key);
      } else {
        int index = scores.indexOf(Collections.min(scores));
        if (scores.get(index) < scoremap.get(key)) {
          scores.set(index, scoremap.get(key));
          urls.set(index, key);
        }
      }
    }

    while (scores.size() > 0) {
      int index = scores.indexOf(Collections.max(scores));
      out.println(urls.get(index) + "\t" + scores.get(index));
      urls.remove(index);
      scores.remove(index);
    }
    out.close();
  }
  private void validateDTD() throws InvalidWorkflowDescriptorException {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);

    StringWriter sw = new StringWriter();
    PrintWriter writer = new PrintWriter(sw);
    writer.println(XML_HEADER);
    writer.println(DOCTYPE_DECL);
    writeXML(writer, 0);

    WorkflowLoader.AllExceptionsErrorHandler errorHandler =
        new WorkflowLoader.AllExceptionsErrorHandler();

    try {
      DocumentBuilder db = dbf.newDocumentBuilder();
      db.setEntityResolver(new DTDEntityResolver());

      db.setErrorHandler(errorHandler);
      db.parse(new InputSource(new StringReader(sw.toString())));

      if (errorHandler.getExceptions().size() > 0) {
        throw new InvalidWorkflowDescriptorException(errorHandler.getExceptions().toString());
      }
    } catch (InvalidWorkflowDescriptorException e) {
      throw e;
    } catch (Exception e) {
      throw new InvalidWorkflowDescriptorException(e.toString());
    }
  }
Example #17
0
 public static void clearPlaylist(Playlist pl) throws Exception {
   String s = pl.NAME;
   // (new File(s)).delete();
   (new File(s + ".dec")).delete();
   PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(new File(s))));
   pw.close();
 }
Example #18
0
 /**
  * Recursive function to sort array of integers using the Quick Sort Algorithm.
  *
  * @param array Array of integers to sort.
  * @param begin The starting index in <code>array</code> of the range to be sorted.
  * @param end The ending index in <code>array</code> of the range to be sorted.
  */
 void sort(int[] array, int begin, int end) {
   int[] arraycpy = new int[array.length];
   for (int i = 0; i < array.length; i++) arraycpy[i] = array[i];
   if (begin < end) {
     // fibQuestion q = new fibQuestion(out, (new Integer(qIndex)).toString());
     // Remember that Animal wants quotes around the question text
     // q.setQuestionText("\"Which number in the array will be chosen as pivot index?\"");
     // questions.addQuestion(q);
     // out.println("{");
     // questions.animalInsertQuestion(qIndex);
     // out.println("}");
     int pivIndex = partition(array, begin, end);
     // After calling on partition, pivIndex is used to set the answer
     // for the question
     // And, remember that Animal wants quotes around the question answer
     // q.setAnswer("\"" + arraycpy[pivIndex] + "\"");
     // qIndex++;
     sort(array, begin, pivIndex - 1);
     sort(array, pivIndex + 1, end);
   } else {
     out.println("{");
     out.println("highlightArrayCell on \"qarray\" position " + begin);
     out.println("}");
   }
 }
Example #19
0
 public void cutPlaylist() throws Exception {
   if (logger.isDebugEnabled()) logger.debug("Cut Playlist.");
   String st;
   PrintWriter pw =
       new PrintWriter(new BufferedWriter(new FileWriter(new File(this.NAME + ".dec"))));
   BufferedReader br = new BufferedReader(new FileReader(new File(this.NAME)));
   if ((st = br.readLine()) != null) {
     String st2[];
     st = new File(st).toURL().toString();
     st2 = st.split("/");
     StringBuffer stb = new StringBuffer(st2[st2.length - 1]);
     StringBuffer stb2 = stb.reverse();
     String st3 = new String(stb2);
     int i = 0;
     while (st3.charAt(i) != '.') i++;
     String a = st3.substring(i + 1, st3.length());
     pw.print(new StringBuffer(a).reverse());
   }
   while ((st = br.readLine()) != null) {
     pw.println();
     String st2[];
     st = new File(st).toURL().toString();
     st2 = st.split("/");
     StringBuffer stb = new StringBuffer(st2[st2.length - 1]);
     StringBuffer stb2 = stb.reverse();
     String st3 = new String(stb2);
     int i = 0;
     while (st3.charAt(i) != '.') i++;
     String a = st3.substring(i + 1, st3.length());
     pw.print(new StringBuffer(a).reverse());
   }
   pw.close();
   br.close();
 }
Example #20
0
  public static void main(String[] args) throws IOException {
    input.init(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int depth = input.nextInt();
    int n = (1 << (depth + 1));
    int[] as = new int[n];
    for (int i = 2; i < n; i++) as[i] = input.nextInt();
    int[] paths = new int[n];
    int max = 0;
    ArrayList<Integer>[] under = new ArrayList[n];
    for (int i = 0; i < n; i++) under[i] = new ArrayList<Integer>();
    for (int i = (1 << (depth)); i < n; i++) {
      int cur = i;
      while (cur > 1) {
        under[cur].add(i);
        paths[i] += as[cur];
        cur /= 2;
      }
      max = Math.max(max, paths[i]);
    }
    int res = 0;
    for (int i = 2; i < n; i++) {
      int cm = 0;
      for (int x : under[i]) cm = Math.max(cm, paths[x]);
      int diff = max - cm;
      res += diff;
      for (int x : under[i]) paths[x] += diff;
    }
    out.println(res);
    out.close();
  }
 public static void main(String[] args) throws IOException {
   BufferedReader f = new BufferedReader(new FileReader("barn1.in"));
   out = new PrintWriter(new BufferedWriter(new FileWriter("barn1.out")));
   StringTokenizer nstr = new StringTokenizer(f.readLine());
   int m = Integer.parseInt(nstr.nextToken());
   int s = Integer.parseInt(nstr.nextToken());
   occupied = new ArrayList<ArrayList<Integer>>();
   occupied.add(new ArrayList<Integer>());
   for (int i = 0; i < s; i++) {
     try {
       nstr = new StringTokenizer(f.readLine());
       occupied.get(0).add(Integer.parseInt(nstr.nextToken()));
     } catch (NullPointerException e) {
       break;
     }
   }
   Collections.sort(occupied.get(0));
   int bound = m - 1;
   if (occupied.get(0).size() - 1 < bound) {
     bound = occupied.get(0).size() - 1;
   }
   for (int i = 0; i < bound; i++) {
     findMaxCut();
   }
   int total = 0;
   int len = occupied.size();
   for (int i = 0; i < len; i++) {
     ArrayList<Integer> arr = occupied.get(i);
     int len2 = arr.size();
     total += arr.get(len2 - 1) - arr.get(0) + 1;
   }
   out.println(total);
   out.close();
   System.exit(0);
 }
  public static void main(String[] args) throws IOException {
    BufferedReader f = new BufferedReader(new FileReader("beads.in"));
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("beads.out")));
    int n = Integer.parseInt(f.readLine());
    String s = f.readLine();
    int max = Integer.MIN_VALUE;

    for (int i = 0; i < n; i++) {
      String straight = s.substring(i + 1) + s.substring(0, i + 1);
      char[] beads = straight.toCharArray();
      int temp = 0;
      char color = ' ';
      for (int j = 0; j < n; j++) {
        char currColor = beads[j];
        if (color == ' ' && currColor != 'w') color = currColor;
        if (currColor == color || currColor == 'w') temp++;
        else break;
      }

      color = ' ';
      for (int j = n - 1; j > -1; j--) {
        char currColor = beads[j];
        if (color == ' ' && currColor != 'w') color = currColor;
        if (currColor == color || currColor == 'w') temp++;
        else break;
      }
      max = Math.max(temp, max);
    }
    if (max > n) max = n;
    out.println(max);
    out.close();
    System.exit(0);
  }
Example #23
0
  public void solve() throws IOException {
    int n = in.nextInt();
    int m = in.nextInt();
    graph = new ArrayList[n + 1];
    color = new int[n + 1];
    Arrays.fill(color, 0);

    for (int i = 0; i < m; i++) {
      int from = in.nextInt();
      int to = in.nextInt();
      if (graph[from] == null) {
        graph[from] = new ArrayList<Integer>();
      }
      graph[from].add(to);
    }

    topSort();
    if (hasCycle) {
      out.print(-1);
      return;
    }

    for (Integer anAnswer : answer) {
      out.printf("%d ", anAnswer);
    }
  }
  public void solve() throws IOException {
    MyReader in = new MyReader();
    PrintWriter out = new PrintWriter(System.out);

    while (true) {
      int n = in.nextInt();
      if (n == 0) break;
      int m = in.nextInt(), g = in.nextInt(), score[] = new int[m];
      for (int i = 0; i < m; i++) score[i] = in.nextInt();

      Student students[] = new Student[n];
      for (int i = 0; i < n; i++) {
        String name = in.next();
        int cnt = in.nextInt(), totScore = 0;
        for (int j = 0; j < cnt; j++) totScore += score[in.nextInt() - 1];
        students[i] = new Student(name, totScore);
      }
      Arrays.sort(students);

      int pass_cnt = 0;
      for (; pass_cnt < n && students[pass_cnt].getScore() >= g; pass_cnt++) ;
      out.println(pass_cnt);
      for (int i = 0; i < pass_cnt; i++) students[i].print(out);

      out.flush();
    }
  }
  // write output, each sentence on a line
  // <word1>/<postag1> <word2>/<postag2> ...
  public void writeData(Map lbInt2Str, String outputFile) {
    if (data == null) {
      return;
    }

    PrintWriter fout = null;

    try {
      fout = new PrintWriter(new FileWriter(outputFile));

      // main loop for writing
      for (int i = 0; i < data.size(); i++) {
        List seq = (List) data.get(i);
        for (int j = 0; j < seq.size(); j++) {
          Observation obsr = (Observation) seq.get(j);
          fout.print(obsr.toString(lbInt2Str) + " ");
        }
        fout.println();
      }

      fout.close();

    } catch (IOException e) {
      System.out.println("Couldn't create file: " + outputFile);
      return;
    }
  }
Example #26
0
 public void totalExport() {
   File expf = new File("export");
   if (expf.exists()) rmrf(expf);
   expf.mkdirs();
   for (int sto = 0; sto < storeLocs.size(); sto++) {
     try {
       String sl =
           storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-");
       File estore = new File(expf, sl);
       estore.mkdir();
       File log = new File(estore, LIBRARY_NAME);
       PrintWriter pw = new PrintWriter(log);
       for (int i = 0; i < store.getRowCount(); i++)
         if (store.curStore(i) == sto) {
           File enc = store.locate(i);
           File dec = sec.prepareMainFile(enc, estore, false);
           pw.println(dec.getName());
           pw.println(store.getValueAt(i, Storage.COL_DATE));
           pw.println(store.getValueAt(i, Storage.COL_TAGS));
           synchronized (jobs) {
             jobs.addLast(expJob(enc, dec));
           }
         }
       pw.close();
     } catch (IOException exc) {
       exc.printStackTrace();
       JOptionPane.showMessageDialog(frm, "Exporting Failed");
       return;
     }
   }
   JOptionPane.showMessageDialog(frm, "Exporting to:\n   " + expf.getAbsolutePath());
 }
 private boolean write(String message) {
   if (socket != null) {
     p.println(message);
     p.flush();
   }
   return true;
 }
  public static void main(String args[]) throws Exception {
    BufferedReader in = new BufferedReader(new FileReader("important.in"));
    PrintWriter out = new PrintWriter("important.out");

    int n = rInt(in.readLine(), 1, MaxN);

    boolean[] t = new boolean[26];

    for (int i = 0; i < n; i++) {
      String s = in.readLine();
      if (s.length() > MaxL) throw new Exception("String is too long");
      char f = checkFormula(s.trim());
      t[f - 'A'] = true;
    }
    ;

    out.println("Yes");

    boolean flag = false;
    for (int i = 0; i < 26; i++)
      if (t[i]) {
        if (flag) out.print(" | ");
        String let = "" + (char) (i + 'A');
        out.print(let + " | ~" + let);
        flag = true;
      }
    ;

    out.close();
  };
  public void run() {
    System.out.println("New Communication Thread Started");

    try {
      PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
      BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

      String inputLine;
      String[] inputTemp = new String[3];

      while ((inputLine = in.readLine()) != null) {
        System.out.println("Server: " + inputLine);

        out.println(inputLine);

        if (inputLine.equals("Bye.")) break;
      }

      out.close();
      in.close();
      clientSocket.close();
    } catch (IOException e) {
      System.err.println("Problem with Communication Server");
      System.exit(1);
    }
  }
Example #30
0
  private void writeJarOptions(
      String inputEntryOptionName, String outputEntryOptionName, ClassPath classPath) {
    if (classPath != null) {
      for (int index = 0; index < classPath.size(); index++) {
        ClassPathEntry entry = classPath.get(index);
        String optionName = entry.isOutput() ? outputEntryOptionName : inputEntryOptionName;

        writer.print(optionName);
        writer.print(' ');
        writer.print(relativeFileName(entry.getFile()));

        // Append the filters, if any.
        boolean filtered = false;

        // For backward compatibility, the aar and apk filters come
        // first.
        filtered = writeFilter(filtered, entry.getAarFilter());
        filtered = writeFilter(filtered, entry.getApkFilter());
        filtered = writeFilter(filtered, entry.getZipFilter());
        filtered = writeFilter(filtered, entry.getEarFilter());
        filtered = writeFilter(filtered, entry.getWarFilter());
        filtered = writeFilter(filtered, entry.getJarFilter());
        filtered = writeFilter(filtered, entry.getFilter());

        if (filtered) {
          writer.print(ConfigurationConstants.CLOSE_ARGUMENTS_KEYWORD);
        }

        writer.println();
      }
    }
  }