コード例 #1
0
 String javap(String... args) {
   StringWriter sw = new StringWriter();
   PrintWriter out = new PrintWriter(sw);
   // sun.tools.javap.Main.entry(args);
   int rc = com.sun.tools.javap.Main.run(args, out);
   if (rc != (args.length == 0 ? 2 : 0)) throw new Error("javap failed. rc=" + rc);
   out.close();
   return sw.toString();
 }
コード例 #2
0
ファイル: Installer.java プロジェクト: suever/CTP
 private String getFileText(File file) throws Exception {
   BufferedReader br =
       new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
   StringWriter sw = new StringWriter();
   int n;
   char[] cbuf = new char[1024];
   while ((n = br.read(cbuf, 0, cbuf.length)) != -1) sw.write(cbuf, 0, n);
   br.close();
   return sw.toString();
 }
コード例 #3
0
ファイル: JarDiff.java プロジェクト: psndcsrv/jnlp-servlet
  /**
   * Writes the index file out to <code>jos</code>. <code>oldEntries</code> gives the names of the
   * files that were removed, <code>movedMap</code> maps from the new name to the old name.
   */
  private static void createIndex(JarOutputStream jos, List oldEntries, Map movedMap)
      throws IOException {
    StringWriter writer = new StringWriter();

    writer.write(VERSION_HEADER);
    writer.write("\r\n");

    // Write out entries that have been removed
    for (int counter = 0; counter < oldEntries.size(); counter++) {
      String name = (String) oldEntries.get(counter);

      writer.write(REMOVE_COMMAND);
      writer.write(" ");
      writeEscapedString(writer, name);
      writer.write("\r\n");
    }

    // And those that have moved
    Iterator names = movedMap.keySet().iterator();

    if (names != null) {
      while (names.hasNext()) {
        String newName = (String) names.next();
        String oldName = (String) movedMap.get(newName);

        writer.write(MOVE_COMMAND);
        writer.write(" ");
        writeEscapedString(writer, oldName);
        writer.write(" ");
        writeEscapedString(writer, newName);
        writer.write("\r\n");
      }
    }

    JarEntry je = new JarEntry(INDEX_NAME);
    byte[] bytes = writer.toString().getBytes("UTF-8");

    writer.close();
    jos.putNextEntry(je);
    jos.write(bytes, 0, bytes.length);
  }