java.io.PrintWriter

Here are the examples of the java api class java.io.PrintWriter taken from open source projects.

1. MdParserTest#createSampleFile()

Project: jbake
Source File: MdParserTest.java
View license
@Before
public void createSampleFile() throws Exception {
    configFile = new File(this.getClass().getResource(".").getFile());
    config = ConfigUtil.load(configFile);
    validMdFileBasic = folder.newFile("validBasic.md");
    PrintWriter out = new PrintWriter(validMdFileBasic);
    out.println(validHeader);
    out.println("# This is a test");
    out.close();
    invalidMdFileBasic = folder.newFile("invalidBasic.md");
    out = new PrintWriter(invalidMdFileBasic);
    out.println(invalidHeader);
    out.println("# This is a test");
    out.close();
    mdFileHardWraps = folder.newFile("hardWraps.md");
    out = new PrintWriter(mdFileHardWraps);
    out.println(validHeader);
    out.println("First line");
    out.println("Second line");
    out.close();
    mdFileAbbreviations = folder.newFile("abbreviations.md");
    out = new PrintWriter(mdFileAbbreviations);
    out.println(validHeader);
    out.println("*[HTML]: Hyper Text Markup Language");
    out.println("HTML");
    out.close();
    mdFileAutolinks = folder.newFile("autolinks.md");
    out = new PrintWriter(mdFileAutolinks);
    out.println(validHeader);
    out.println("http://github.com");
    out.close();
    mdFileDefinitions = folder.newFile("definitions.md");
    out = new PrintWriter(mdFileDefinitions);
    out.println(validHeader);
    out.println("Apple");
    out.println(":   Pomaceous fruit");
    out.close();
    mdFileFencedCodeBlocks = folder.newFile("fencedCodeBlocks.md");
    out = new PrintWriter(mdFileFencedCodeBlocks);
    out.println(validHeader);
    out.println("```");
    out.println("function test() {");
    out.println("  console.log(\"!\");");
    out.println("}");
    out.println("```");
    out.close();
    mdFileQuotes = folder.newFile("quotes.md");
    out = new PrintWriter(mdFileQuotes);
    out.println(validHeader);
    out.println("\"quotes\"");
    out.close();
    mdFileSmarts = folder.newFile("smarts.md");
    out = new PrintWriter(mdFileSmarts);
    out.println(validHeader);
    out.println("...");
    out.close();
    mdFileSmartypants = folder.newFile("smartypants.md");
    out = new PrintWriter(mdFileSmartypants);
    out.println(validHeader);
    out.println("\"...\"");
    out.close();
    mdFileSuppressAllHTML = folder.newFile("suppressAllHTML.md");
    out = new PrintWriter(mdFileSuppressAllHTML);
    out.println(validHeader);
    out.println("<div>!</div><em>!</em>");
    out.close();
    mdFileSuppressHTMLBlocks = folder.newFile("suppressHTMLBlocks.md");
    out = new PrintWriter(mdFileSuppressHTMLBlocks);
    out.println(validHeader);
    // TODO (ksclarke): this looks like an upstream bug (not suppressed):
    // out.println("<div>!</div><em>!</em>");
    // But this works:
    out.println("<div>!</div>");
    out.println("<em>!</em>");
    out.close();
    mdFileSuppressInlineHTML = folder.newFile("suppressInlineHTML.md");
    out = new PrintWriter(mdFileSuppressInlineHTML);
    out.println(validHeader);
    // TODO: (JSB) this looks like an upstream bug in 1.6.0, none of this inline HTML is not suppressed at all in output:
    // out.println("<div>!</div>");
    // out.println("<em>!</em>");
    // but this is suppressed in output:
    // out.println("<div>!</div><em>!</em>");
    out.println("This is the first paragraph.");
    out.println();
    out.println("<div>!</div><em>!</em>");
    out.println();
    out.println("This is the second paragraph.");
    out.close();
    mdFileTables = folder.newFile("tables.md");
    out = new PrintWriter(mdFileTables);
    out.println(validHeader);
    out.println("First Header|Second Header");
    out.println("-------------|-------------");
    out.println("Content Cell|Content Cell");
    out.println("Content Cell|Content Cell");
    out.close();
    mdFileWikilinks = folder.newFile("wikilinks.md");
    out = new PrintWriter(mdFileWikilinks);
    out.println(validHeader);
    out.println("[[Wiki-style links]]");
    out.close();
}

2. WebConsoleFtpLet#doGet()

Project: sling
Source File: WebConsoleFtpLet.java
View license
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    final PrintWriter pw = resp.getWriter();
    final Date start = this.stats.getStartTime();
    final long uptime = (System.currentTimeMillis() - start.getTime()) / 1000;
    pw.print("<p class=\"statline ui-state-highlight\">");
    pw.printf("FTP Server active. Started: %s. Uptime %d:%02d:%02d.", start, uptime / 3600, uptime / 60 % 60, uptime % 60);
    pw.println("</p>");
    pw.println("<table class=\"nicetable\">");
    pw.println("<tr>");
    pw.println("<th>Connections</th>");
    pw.println("<th>Anonymous Logins</th>");
    pw.println("<th>Authenticated Logins</th>");
    pw.println("<th>Total</th>");
    pw.println("<th>Failed</th>");
    pw.println("</tr>");
    pw.println("<tr>");
    pw.println("<th>Current</th>");
    pw.printf("<td>%d</td>%n", this.stats.getCurrentAnonymousLoginNumber());
    pw.printf("<td>%d</td>%n", this.stats.getCurrentLoginNumber());
    pw.printf("<td>%d</td>%n", this.stats.getCurrentConnectionNumber());
    pw.printf("<td> </td>%n");
    pw.println("</tr>");
    pw.println("<tr>");
    pw.println("<th>Total</th>");
    pw.printf("<td>%d</td>%n", this.stats.getTotalAnonymousLoginNumber());
    pw.printf("<td>%d</td>%n", this.stats.getTotalConnectionNumber());
    pw.printf("<td>%d</td>%n", this.stats.getTotalLoginNumber());
    pw.printf("<td>%d</td>%n", this.stats.getTotalFailedLoginNumber());
    pw.println("</tr>");
    pw.println("</table>");
    pw.println("<p> </p>");
    pw.println("<table class=\"nicetable\">");
    pw.println("<tr>");
    pw.println("<th colspan='2'>Operations</th>");
    pw.println("</tr>");
    pw.println("<tr>");
    pw.println("<th>Directory</th>");
    pw.printf("<td>%d created, %d removed</td>%n", this.stats.getTotalDirectoryCreated(), this.stats.getTotalDirectoryRemoved());
    pw.println("</tr>");
    pw.println("<tr>");
    pw.println("<th>File Removals</th>");
    pw.printf("<td>%d</td>%n", this.stats.getTotalDeleteNumber());
    pw.println("</tr>");
    pw.println("<tr>");
    pw.println("<th>File Uploads</th>");
    pw.printf("<td>%d (%d MB)</td>%n", this.stats.getTotalUploadNumber(), this.stats.getTotalUploadSize() / 1024 / 1024);
    pw.println("</tr>");
    pw.println("</tr>");
    pw.println("<tr>");
    pw.println("<th>File Downloads</th>");
    pw.printf("<td>%d (%d MB)</td>%n", this.stats.getTotalDownloadNumber(), this.stats.getTotalDownloadSize() / 1024 / 1024);
    pw.println("</tr>");
    pw.println("</table>");
    pw.println("<p> </p>");
    pw.println("<table class=\"nicetable\">");
    pw.println("<tr>");
    pw.println("<th>Session ID</th>");
    pw.println("<th>User</th>");
    pw.println("<th>Address</th>");
    pw.println("<th>Connected</th>");
    pw.println("<th>Logged In</th>");
    pw.println("<th>Last Access</th>");
    pw.println("<th>Max Idle Time (s)</th>");
    pw.println("</tr>");
    for (SessionEntry entry : this.sessions.values()) {
        final FtpSession session = entry.getSession();
        /*
             * Display a subset of the session information. The following
             * is omitted for now:
             *  - session.getDataType();
             *  - session.getFailedLogins();
             *  - session.getFileOffset();
             *  - session.getLanguage()
             *  - session.getUserArgument();
             *  - session.getStructure();
             */
        pw.println("<tr>");
        pw.printf("<td>%s</td>%n", session.getSessionId());
        pw.printf("<td>%s</td>%n", session.getUser().getName());
        pw.printf("<td>%s:%s</td>%n", session.getClientAddress().getAddress().getHostAddress(), session.getClientAddress().getPort());
        pw.printf("<td>%1$tF %1$tT</td>%n", session.getConnectionTime());
        pw.printf("<td>%1$tF %1$tT</td>%n", session.getLoginTime());
        pw.printf("<td>%1$tF %1$tT</td>%n", session.getLastAccessTime());
        pw.printf("<td>%d</td>%n", session.getMaxIdleTime());
        pw.println("</tr>");
        if (entry.getRequestLine() != null) {
            pw.println("<tr>");
            pw.printf("<td> </td>%n");
            pw.printf("<td colspan='6'>%s</td>%n", entry.getRequestLine());
            pw.println("</tr>");
        }
    }
    pw.println("</table>");
}

3. GenerateBidiClass#convertBidiClassProperties()

Project: fop
Source File: GenerateBidiClass.java
View license
/**
     * Generate a class managing bidi class properties for Unicode characters.
     *
     * @param bidiFileName name (as URL) of file containing bidi type data
     * @param outFileName name of the output file
     * @throws Exception
     */
private static void convertBidiClassProperties(String bidiFileName, String outFileName) throws Exception {
    readBidiClassProperties(bidiFileName);
    // generate class
    PrintWriter out = new PrintWriter(new FileWriter(outFileName));
    License.writeJavaLicenseId(out);
    out.println();
    out.println("package org.apache.fop.complexscripts.bidi;");
    out.println();
    out.println("import java.util.Arrays;");
    out.println("import org.apache.fop.complexscripts.bidi.BidiConstants;");
    out.println();
    out.println("// CSOFF: WhitespaceAfterCheck");
    out.println("// CSOFF: LineLengthCheck");
    out.println();
    out.println("/*");
    out.println(" * !!! THIS IS A GENERATED FILE !!!");
    out.println(" * If updates to the source are needed, then:");
    out.println(" * - apply the necessary modifications to");
    out.println(" *   'src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/GenerateBidiClass.java'");
    out.println(" * - run 'ant codegen-unicode', which will generate a new BidiClass.java");
    out.println(" *   in 'src/java/org/apache/fop/complexscripts/bidi'");
    out.println(" * - commit BOTH changed files");
    out.println(" */");
    out.println();
    out.println("/** Bidirectional class utilities. */");
    out.println("public final class BidiClass {");
    out.println();
    out.println("private BidiClass() {");
    out.println("}");
    out.println();
    dumpData(out);
    out.println("/**");
    out.println(" * Lookup bidi class for character expressed as unicode scalar value.");
    out.println(" * @param ch a unicode scalar value");
    out.println(" * @return bidi class");
    out.println(" */");
    out.println("public static int getBidiClass ( int ch ) {");
    out.println("  if ( ch <= 0x00FF ) {");
    out.println("    return bcL1 [ ch - 0x0000 ];");
    out.println("  } else if ( ( ch >= 0x0590 ) && ( ch <= 0x06FF ) ) {");
    out.println("    return bcR1 [ ch - 0x0590 ];");
    out.println("  } else {");
    out.println("    return getBidiClass ( ch, bcS1, bcE1, bcC1 );");
    out.println("  }");
    out.println("}");
    out.println();
    out.println("private static int getBidiClass ( int ch, int[] sa, int[] ea, byte[] ca ) {");
    out.println("  int k = Arrays.binarySearch ( sa, ch );");
    out.println("  if ( k >= 0 ) {");
    out.println("    return ca [ k ];");
    out.println("  } else {");
    out.println("    k = - ( k + 1 );");
    out.println("    if ( k == 0 ) {");
    out.println("      return BidiConstants.L;");
    out.println("    } else if ( ch <= ea [ k - 1 ] ) {");
    out.println("      return ca [ k - 1 ];");
    out.println("    } else {");
    out.println("      return BidiConstants.L;");
    out.println("    }");
    out.println("  }");
    out.println("}");
    out.println();
    out.println("}");
    out.flush();
    out.close();
}

4. ParserTest#createSampleFile()

Project: jbake
Source File: ParserTest.java
View license
@Before
public void createSampleFile() throws Exception {
    rootPath = new File(this.getClass().getResource(".").getFile());
    config = ConfigUtil.load(rootPath);
    parser = new Parser(config, rootPath.getPath());
    validHTMLFile = folder.newFile("valid.html");
    PrintWriter out = new PrintWriter(validHTMLFile);
    out.println(validHeader);
    out.println("<p>This is a test.</p>");
    out.close();
    invalidHTMLFile = folder.newFile("invalid.html");
    out = new PrintWriter(invalidHTMLFile);
    out.println(invalidHeader);
    out.close();
    validAsciiDocFile = folder.newFile("valid.ad");
    out = new PrintWriter(validAsciiDocFile);
    out.println(validHeader);
    out.println("= Hello, AsciiDoc!");
    out.println("Test User <[email protected]>");
    out.println("");
    out.println("JBake now supports AsciiDoc.");
    out.close();
    invalidAsciiDocFile = folder.newFile("invalid.ad");
    out = new PrintWriter(invalidAsciiDocFile);
    out.println(invalidHeader);
    out.println("= Hello, AsciiDoc!");
    out.println("Test User <[email protected]>");
    out.println("");
    out.println("JBake now supports AsciiDoc.");
    out.close();
    validAsciiDocFileWithoutHeader = folder.newFile("validwoheader.ad");
    out = new PrintWriter(validAsciiDocFileWithoutHeader);
    out.println("= Hello: AsciiDoc!");
    out.println("Test User <[email protected]>");
    out.println("2013-09-02");
    out.println(":jbake-status: published");
    out.println(":jbake-type: page");
    out.println("");
    out.println("JBake now supports AsciiDoc.");
    out.close();
    invalidAsciiDocFileWithoutHeader = folder.newFile("invalidwoheader.ad");
    out = new PrintWriter(invalidAsciiDocFileWithoutHeader);
    out.println("= Hello, AsciiDoc!");
    out.println("Test User <[email protected]>");
    out.println("2013-09-02");
    out.println(":jbake-status: published");
    out.println("");
    out.println("JBake now supports AsciiDoc.");
    out.close();
    validAsciiDocFileWithHeaderInContent = folder.newFile("validheaderincontent.ad");
    out = new PrintWriter(validAsciiDocFileWithHeaderInContent);
    out.println("= Hello, AsciiDoc!");
    out.println("Test User <[email protected]>");
    out.println("2013-09-02");
    out.println(":jbake-status: published");
    out.println(":jbake-type: page");
    out.println("");
    out.println("JBake now supports AsciiDoc.");
    out.println("");
    out.println("----");
    out.println("title=Example Header");
    out.println("date=2013-02-01");
    out.println("type=post");
    out.println("tags=tag1, tag2");
    out.println("status=published");
    out.println("~~~~~~");
    out.println("----");
    out.close();
}

5. GenerateBidiTestData#convertBidiTestData()

Project: fop
Source File: GenerateBidiTestData.java
View license
/**
     * Generate a class managing bidi test data for Unicode characters.
     *
     * @param ucdFileName name (as URL) of file containing unicode character database data
     * @param bidiFileName name (as URL) of file containing bidi test data
     * @param outFileName name of the output class file
     * @throws Exception
     */
private static void convertBidiTestData(String ucdFileName, String bidiFileName, String outFileName) throws Exception {
    // read type data from UCD if ignoring deprecated type data
    if (ignoreDeprecatedTypeData) {
        readBidiTypeData(ucdFileName);
    }
    // read bidi test data
    readBidiTestData(bidiFileName);
    // generate class
    PrintWriter out = new PrintWriter(new FileWriter(outFileName));
    License.writeJavaLicenseId(out);
    out.println();
    out.println("package org.apache.fop.complexscripts.bidi;");
    out.println();
    out.println("import java.io.IOException;");
    out.println("import java.io.InputStream;");
    out.println("import java.io.ObjectInputStream;");
    out.println();
    out.println("// CSOFF: WhitespaceAfterCheck");
    out.println();
    out.println("/*");
    out.println(" * !!! THIS IS A GENERATED FILE !!!");
    out.println(" * If updates to the source are needed, then:");
    out.println(" * - apply the necessary modifications to");
    out.println(" *   'src/codegen/unicode/java/org/apache/fop/text/bidi/GenerateBidiTestData.java'");
    out.println(" * - run 'ant codegen-unicode', which will generate a new BidiTestData.java");
    out.println(" *   in 'test/java/org/apache/fop/complexscripts/bidi'");
    out.println(" * - commit BOTH changed files");
    out.println(" */");
    out.println();
    out.println("/** Bidirectional test data. */");
    out.println("public final class BidiTestData {");
    out.println();
    out.println("    private BidiTestData() {");
    out.println("    }");
    out.println();
    dumpData(out, outFileName);
    out.println("    public static final int NUM_TEST_SEQUENCES = " + numTestSpecs + ";");
    out.println();
    out.println("    public static int[] readTestData ( String prefix, int index ) {");
    out.println("        int[] data = null;");
    out.println("        InputStream is = null;");
    out.println("        Class btc = BidiTestData.class;");
    out.println("        String name = btc.getSimpleName() + \"$\" + prefix + index + \".ser\";");
    out.println("        try {");
    out.println("            if ( ( is = btc.getResourceAsStream ( name ) ) != null ) {");
    out.println("                ObjectInputStream ois = new ObjectInputStream ( is );");
    out.println("                data = (int[]) ois.readObject();");
    out.println("                ois.close();");
    out.println("            }");
    out.println("        } catch ( IOException e ) {");
    out.println("            data = null;");
    out.println("        } catch ( ClassNotFoundException e ) {");
    out.println("            data = null;");
    out.println("        } finally {");
    out.println("            if ( is != null ) {");
    out.println("                try { is.close(); } catch ( Exception e ) {}");
    out.println("            }");
    out.println("        }");
    out.println("        return data;");
    out.println("    }");
    out.println("}");
    out.flush();
    out.close();
}

6. OSGiBundleRepositoryServlet#listBundles()

View license
private void listBundles(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String category = this.getParameter(req, "category", Repository.CATEGORY_ALL_BUNDLES);
    String regexp = this.getParameter(req, "regexp", "");
    Pattern pattern = null;
    if (regexp.length() > 0) {
        try {
            String regexpInt = regexp;
            // turn regexp into substring match if not bounded by ^/$
            if (!regexpInt.startsWith("^") && !regexpInt.startsWith(".*"))
                regexpInt = ".*" + regexpInt;
            if (!regexpInt.endsWith("$") && !regexpInt.endsWith(".*"))
                regexpInt = regexpInt + ".*";
            pattern = Pattern.compile(regexpInt);
        } catch (PatternSyntaxException pse) {
            regexp = "";
        }
    }
    // set cookies
    this.setCookie(resp, "category", category);
    this.setCookie(resp, "regexp", regexp);
    PrintWriter pw = this.head(resp);
    pw.print("<h1>Welcome to the OSGi Bundle Repository ");
    pw.print(this.repository.getName());
    pw.println("</h1>");
    pw.print("<p>This repository was last updated: ");
    pw.println(new Date(this.repository.getLastModified()));
    pw.println("<hr />");
    pw.println("<h2>Tasks</h2>");
    pw.println("<table border='0' width='100%'>");
    pw.print("<tr><td nowrap>Repository Descriptor</td>");
    pw.print("<td width='99%'><a href='");
    pw.print(this.getRelativeURI(req, "repository.xml"));
    pw.print("'>");
    pw.print("repository.xml");
    pw.println("</a></td></tr>");
    pw.print("<tr><td nowrap>Repository Download (complete)</td>");
    pw.print("<td width='99%'><a href='");
    pw.print(this.getRelativeURI(req, "repository.zip"));
    pw.print("'>");
    pw.print("repository.zip");
    pw.println("</a></td><tr>");
    pw.print("<tr><td nowrap>Bundle Upload</td>");
    pw.print("<td width='99%'><form method='POST' enctype='multipart/form-data'>");
    pw.print("<input type='file' name='bundlefile'>");
    pw.print("<input type='submit' value='Upload Bundle'>");
    pw.print("</form>");
    pw.println("</td></tr>");
    pw.println("</table>");
    pw.println("<hr />");
    pw.println("<form name='selection'>");
    pw.println("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
    pw.println("<tr><td><h2>Available Resources</h2></td>");
    pw.println("<td align='right'>");
    pw.println("By Name (Reg Exp): <input type='text' name='regexp' value='" + regexp + "'>");
    pw.println("  |  ");
    pw.println("By Category: <select name='category' onChange='form.submit();'>");
    Iterator categories = this.repository.getBundleCategories(null).iterator();
    while (categories.hasNext()) {
        Object cat = categories.next();
        String selected = category.equals(cat) ? "selected" : "";
        pw.print("<option value='" + cat + "' " + selected + ">");
        pw.print(cat);
        pw.println("</option>");
    }
    pw.println("</select>");
    pw.println("  |  ");
    pw.println("<input type='submit' value='Show'/>");
    pw.println("  |  ");
    pw.println("<input type='button' value='Download Selected' onClick='document.forms[\"selectiveDump\"].submit();'");
    pw.println("</td></tr>");
    pw.println("</table>");
    pw.println("</form>");
    pw.print("<form name='selectiveDump' method='post' action='" + this.getRelativeURI(req, "repository.zip") + "'>");
    pw.println("<center>");
    pw.println("<table width='80%' border='1' cellspacing='0' cellpadding='3'>");
    boolean haveBundles = false;
    Iterator bi = this.repository.getResourcesByCategory(category);
    while (bi.hasNext()) {
        Resource res = (Resource) bi.next();
        // ignore the resource if the name does not match the regexp
        if (pattern != null && !pattern.matcher(res.getSymbolicName()).matches()) {
            continue;
        }
        String uri = this.getRelativeURI(req, res.getResourceName());
        this.dumpRow(pw, "<input name='bundle' type='checkbox' value='" + res.getResourceName() + "'></td><td><a href='" + uri + "?info=info" + "'>" + res + "</a>", "<a href='" + uri + "?remove=remove" + "'>remove</a>");
        haveBundles = true;
    }
    // indicate no matching bundles
    if (!haveBundles) {
        StringBuffer msg = new StringBuffer();
        msg.append("No Bundle found ");
        if (pattern != null) {
            msg.append("whose Symbolic Name matches regular expression '");
            msg.append(pattern.pattern());
            msg.append("' and ");
        }
        msg.append("which has Category " + category);
        this.dumpRow(pw, msg.toString(), null);
    }
    pw.println("</table>");
    pw.println("</center>");
    pw.println("</form>");
    this.foot(pw);
}

7. TestFairScheduler#testAllocationFileParsing()

Project: hadoop-20
Source File: TestFairScheduler.java
View license
public void testAllocationFileParsing() throws Exception {
    PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
    out.println("<?xml version=\"1.0\"?>");
    out.println("<allocations>");
    // Give pool A a minimum of 1 map, 2 reduces
    out.println("<pool name=\"pool_a\">");
    out.println("<minMaps>1</minMaps>");
    out.println("<minReduces>2</minReduces>");
    out.println("<maxTotalInitedTasks>100000</maxTotalInitedTasks>");
    out.println("</pool>");
    // Give pool B a minimum of 2 maps, 1 reduce
    out.println("<pool name=\"pool_b\">");
    out.println("<minMaps>2</minMaps>");
    out.println("<minReduces>1</minReduces>");
    out.println("</pool>");
    // Give pool B a maximum of 4 maps, 2 reduce
    out.println("<pool name=\"pool_b\">");
    out.println("<maxMaps>4</maxMaps>");
    out.println("<maxReduces>2</maxReduces>");
    out.println("<maxTotalInitedTasks>20000</maxTotalInitedTasks>");
    out.println("</pool>");
    // Give pool C min maps but no min reduces
    out.println("<pool name=\"pool_c\">");
    out.println("<minMaps>2</minMaps>");
    out.println("</pool>");
    // Give pool C a maximum of 4 maps, no maximum reduces
    out.println("<pool name=\"pool_c\">");
    out.println("<maxMaps>4</maxMaps>");
    out.println("</pool>");
    // Give pool D a limit of 3 running jobs
    out.println("<pool name=\"pool_d\">");
    out.println("<maxRunningJobs>3</maxRunningJobs>");
    out.println("</pool>");
    // Give pool E a preemption timeout of one minute
    out.println("<pool name=\"pool_e\">");
    out.println("<minSharePreemptionTimeout>60</minSharePreemptionTimeout>");
    out.println("</pool>");
    // Set default limit of jobs per user to 5
    out.println("<userMaxJobsDefault>5</userMaxJobsDefault>");
    // Give user1 a limit of 10 jobs
    out.println("<user name=\"user1\">");
    out.println("<maxRunningJobs>10</maxRunningJobs>");
    out.println("</user>");
    // Set default min share preemption timeout to 2 minutes
    out.println("<defaultMinSharePreemptionTimeout>120" + "</defaultMinSharePreemptionTimeout>");
    // Set fair share preemption timeout to 5 minutes
    out.println("<fairSharePreemptionTimeout>300</fairSharePreemptionTimeout>");
    out.println("<defaultMaxTotalInitedTasks>50000" + "</defaultMaxTotalInitedTasks>");
    out.println("</allocations>");
    out.close();
    PoolManager poolManager = scheduler.getPoolManager();
    poolManager.reloadAllocs();
    // 5 in file + default pool
    assertEquals(6, poolManager.getPools().size());
    assertEquals(0, poolManager.getMinSlots(Pool.DEFAULT_POOL_NAME, TaskType.MAP));
    assertEquals(0, poolManager.getMinSlots(Pool.DEFAULT_POOL_NAME, TaskType.REDUCE));
    assertEquals(1, poolManager.getMinSlots("pool_a", TaskType.MAP));
    assertEquals(2, poolManager.getMinSlots("pool_a", TaskType.REDUCE));
    assertEquals(2, poolManager.getMinSlots("pool_b", TaskType.MAP));
    assertEquals(1, poolManager.getMinSlots("pool_b", TaskType.REDUCE));
    assertEquals(2, poolManager.getMinSlots("pool_c", TaskType.MAP));
    assertEquals(0, poolManager.getMinSlots("pool_c", TaskType.REDUCE));
    assertEquals(0, poolManager.getMinSlots("pool_d", TaskType.MAP));
    assertEquals(0, poolManager.getMinSlots("pool_d", TaskType.REDUCE));
    assertEquals(0, poolManager.getMinSlots("pool_e", TaskType.MAP));
    assertEquals(0, poolManager.getMinSlots("pool_e", TaskType.REDUCE));
    assertEquals(10, poolManager.getUserMaxJobs("user1"));
    assertEquals(5, poolManager.getUserMaxJobs("user2"));
    assertEquals(4, poolManager.getMaxSlots("pool_b", TaskType.MAP));
    assertEquals(2, poolManager.getMaxSlots("pool_b", TaskType.REDUCE));
    assertEquals(4, poolManager.getMaxSlots("pool_c", TaskType.MAP));
    assertEquals(100000, poolManager.getPoolMaxInitedTasks("pool_a"));
    assertEquals(20000, poolManager.getPoolMaxInitedTasks("pool_b"));
    assertEquals(50000, poolManager.getPoolMaxInitedTasks("pool_c"));
    assertEquals(50000, poolManager.getPoolMaxInitedTasks("pool_d"));
    assertEquals(50000, poolManager.getPoolMaxInitedTasks("pool_e"));
    assertEquals(Integer.MAX_VALUE, poolManager.getMaxSlots("pool_c", TaskType.REDUCE));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout(Pool.DEFAULT_POOL_NAME));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("pool_a"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("pool_b"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("pool_c"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("pool_d"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("pool_a"));
    assertEquals(60000, poolManager.getMinSharePreemptionTimeout("pool_e"));
    assertEquals(300000, poolManager.getFairSharePreemptionTimeout());
}

8. NativeDebug#dumpCounters()

Project: openjdk
Source File: NativeDebug.java
View license
/**
     * Dump all Nashorn debug mode counters. Calling this may be better if
     * you want to print all counters. This way you can avoid too many callsites
     * due to counter access itself!!
     * @param self self reference
     * @return undefined
     */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object dumpCounters(final Object self) {
    final PrintWriter out = Context.getCurrentErr();
    out.println("ScriptObject count " + ScriptObject.getCount());
    out.println("Scope count " + Scope.getScopeCount());
    out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
    out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
    out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
    out.println("ScriptFunction invokes " + ScriptFunction.getInvokes());
    out.println("ScriptFunction allocations " + ScriptFunction.getAllocations());
    out.println("PropertyMap count " + PropertyMap.getCount());
    out.println("PropertyMap cloned " + PropertyMap.getClonedCount());
    out.println("PropertyMap history hit " + PropertyMap.getHistoryHit());
    out.println("PropertyMap proto invalidations " + PropertyMap.getProtoInvalidations());
    out.println("PropertyMap proto history hit " + PropertyMap.getProtoHistoryHit());
    out.println("PropertyMap setProtoNewMapCount " + PropertyMap.getSetProtoNewMapCount());
    out.println("Callsite count " + LinkerCallSite.getCount());
    out.println("Callsite misses " + LinkerCallSite.getMissCount());
    out.println("Callsite misses by site at " + LinkerCallSite.getMissSamplingPercentage() + "%");
    LinkerCallSite.getMissCounts(out);
    return UNDEFINED;
}

9. IniConfigTest#buildFile()

Project: directory-kerby
Source File: IniConfigTest.java
View license
/**
     * Build a INI format configuration file.
     */
private void buildFile() throws IOException {
    PrintWriter out = new PrintWriter(new FileWriter(TEST_FILE));
    out.println("#note = notenote");
    out.println("default = FILE:/var/log/krb5libs.log");
    out.println("kdc = FILE:/var/log/krb5kdc.log");
    out.println("admin_server = FILE:/var/log/kadmind.log");
    out.println("[libdefaults]");
    out.println("default_realm = EXAMPLE.COM");
    out.println("dns_lookup_realm = false");
    out.println("dns_lookup_kdc = false");
    out.println("ticket_lifetime = 24h");
    out.println("renew_lifetime = 7d");
    out.println("forwardable = true");
    out.println("[lib1]");
    out.println("default_realm = EXAMPLE.COM1");
    out.println("dns_lookup_realm = true");
    out.close();
}

10. HBaseFsck#printUsageAndExit()

Project: hindex
Source File: HBaseFsck.java
View license
protected HBaseFsck printUsageAndExit() {
    StringWriter sw = new StringWriter(2048);
    PrintWriter out = new PrintWriter(sw);
    out.println("Usage: fsck [opts] {only tables}");
    out.println(" where [opts] are:");
    out.println("   -help Display help options (this)");
    out.println("   -details Display full report of all regions.");
    out.println("   -timelag <timeInSeconds>  Process only regions that " + " have not experienced any metadata updates in the last " + " <timeInSeconds> seconds.");
    out.println("   -sleepBeforeRerun <timeInSeconds> Sleep this many seconds" + " before checking if the fix worked if run with -fix");
    out.println("   -summary Print only summary of the tables and status.");
    out.println("   -metaonly Only check the state of ROOT and META tables.");
    out.println("   -sidelineDir <hdfs://> HDFS path to backup existing meta and root.");
    out.println("");
    out.println("  Metadata Repair options: (expert features, use with caution!)");
    out.println("   -fix              Try to fix region assignments.  This is for backwards compatiblity");
    out.println("   -fixAssignments   Try to fix region assignments.  Replaces the old -fix");
    out.println("   -fixMeta          Try to fix meta problems.  This assumes HDFS region info is good.");
    out.println("   -noHdfsChecking   Don't load/check region info from HDFS." + " Assumes META region info is good. Won't check/fix any HDFS issue, e.g. hole, orphan, or overlap");
    out.println("   -fixHdfsHoles     Try to fix region holes in hdfs.");
    out.println("   -fixHdfsOrphans   Try to fix region dirs with no .regioninfo file in hdfs");
    out.println("   -fixTableOrphans  Try to fix table dirs with no .tableinfo file in hdfs (online mode only)");
    out.println("   -fixHdfsOverlaps  Try to fix region overlaps in hdfs.");
    out.println("   -fixVersionFile   Try to fix missing hbase.version file in hdfs.");
    out.println("   -maxMerge <n>     When fixing region overlaps, allow at most <n> regions to merge. (n=" + DEFAULT_MAX_MERGE + " by default)");
    out.println("   -sidelineBigOverlaps  When fixing region overlaps, allow to sideline big overlaps");
    out.println("   -maxOverlapsToSideline <n>  When fixing region overlaps, allow at most <n> regions to sideline per group. (n=" + DEFAULT_OVERLAPS_TO_SIDELINE + " by default)");
    out.println("   -fixSplitParents  Try to force offline split parents to be online.");
    out.println("   -ignorePreCheckPermission  ignore filesystem permission pre-check");
    out.println("   -fixReferenceFiles  Try to offline lingering reference store files");
    out.println("");
    out.println("  Datafile Repair options: (expert features, use with caution!)");
    out.println("   -checkCorruptHFiles     Check all Hfiles by opening them to make sure they are valid");
    out.println("   -sidelineCorruptHfiles  Quarantine corrupted HFiles.  implies -checkCorruptHfiles");
    out.println("");
    out.println("  Metadata Repair shortcuts");
    out.println("   -repair           Shortcut for -fixAssignments -fixMeta -fixHdfsHoles " + "-fixHdfsOrphans -fixHdfsOverlaps -fixVersionFile -sidelineBigOverlaps -fixReferenceFiles");
    out.println("   -repairHoles      Shortcut for -fixAssignments -fixMeta -fixHdfsHoles");
    out.flush();
    errors.reportError(ERROR_CODE.WRONG_USAGE, sw.toString());
    setRetCode(-2);
    return this;
}

11. TextExtractor#dumpStats()

Project: jackrabbit-oak
Source File: TextExtractor.java
View license
private void dumpStats() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    pw.println("Text extraction stats");
    pw.printf("\t Processed Count           : %d%n", processedCount.get());
    pw.printf("\t   Extraction Count        : %d%n", extractionCount.get());
    pw.printf("\t     Empty Count           : %d%n", emptyCount.get());
    pw.printf("\t     Text Written Count    : %d%n", textWrittenCount.get());
    pw.printf("\t   Parser Error Count      : %d%n", parserErrorCount.get());
    pw.printf("\t   Error Count             : %d%n", errorCount.get());
    pw.printf("\t   Not Supported Count     : %d%n", notSupportedCount.get());
    pw.printf("\t   Already processed Count : %d%n", alreadyExtractedCount.get());
    pw.printf("\t Total bytes read          : %s%n", IOUtils.humanReadableByteCount(totalSizeRead.get()));
    pw.printf("\t Total text extracted      : %s%n", IOUtils.humanReadableByteCount(extractedTextSize.get()));
    pw.printf("\t   Non empty text          : %s%n", IOUtils.humanReadableByteCount(nonEmptyExtractedTextSize.get()));
    pw.printf("\t Time taken                : %d sec%n", timeTaken.get() / 1000);
    pw.close();
    log.info(sw.toString());
}

12. TestAccumulator#createFiles()

Project: pig
Source File: TestAccumulator.java
View license
private static void createFiles() throws IOException {
    new File(INPUT_DIR).mkdirs();
    PrintWriter w = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE1));
    w.println("100\tapple");
    w.println("200\torange");
    w.println("300\tstrawberry");
    w.println("300\tpear");
    w.println("100\tapple");
    w.println("300\tpear");
    w.println("400\tapple");
    w.close();
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE1, INPUT_FILE1);
    w = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE2));
    w.println("100\t");
    w.println("100\t");
    w.println("200\t");
    w.println("200\t");
    w.println("300\tstrawberry");
    w.close();
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE2, INPUT_FILE2);
    w = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE3));
    w.println("100\t1.0");
    w.println("100\t2.0");
    w.println("200\t1.1");
    w.println("200\t2.1");
    w.println("100\t3.0");
    w.println("100\t4.0");
    w.println("200\t3.1");
    w.println("100\t5.0");
    w.println("300\t3.3");
    w.println("400\t");
    w.println("400\t");
    w.close();
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE3, INPUT_FILE3);
    w = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE4));
    w.println("100\thttp://ibm.com,ibm");
    w.println("100\thttp://ibm.com,ibm");
    w.println("200\thttp://yahoo.com,yahoo");
    w.println("300\thttp://sun.com,sun");
    w.close();
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE4, INPUT_FILE4);
}

13. ErrorReportDataModel#toString()

View license
@Override
public String toString() {
    StringWriter sb = new StringWriter();
    PrintWriter pw = new PrintWriter(sb);
    pw.println("============= User email =============");
    pw.println(getUserEmail());
    pw.println();
    pw.println("============= User description of the error =============");
    pw.println(getUserDescription());
    pw.println();
    pw.println("============= Error stack trace =============");
    pw.println(AwsPortalFeedbackFormUtils.getStackTraceFromThrowable(getBug()));
    pw.println();
    pw.println("============= Error status message =============");
    pw.println(getStatusMessage());
    pw.println();
    pw.println(getPlatformEnv().toString());
    return sb.toString();
}

14. DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests1_SPEC2_19_ForwardJSPResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

15. DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests2_SPEC2_19_ForwardServletResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

16. DispatcherReqRespTests3_SPEC2_19_IncludeJSPResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests3_SPEC2_19_IncludeJSPResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests3_SPEC2_19_IncludeJSPResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

17. DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests4_SPEC2_19_IncludeServletResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

18. DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceRequest#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceRequest\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceRequest\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

19. DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

20. DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceRequest#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceRequest\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceRequest\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

21. DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_ForwardServletResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

22. DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceRequest#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceRequest\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceRequest\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

23. DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_IncludeJSPResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

24. DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceRequest#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceRequest\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceRequest\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

25. DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceResponse#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceResponse\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_IncludeServletResourceResponse\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

26. DispatcherTests_SPEC2_19_DispatchServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests_SPEC2_19_DispatchServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests_SPEC2_19_DispatchServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

27. DispatcherTests_SPEC2_19_ForwardServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests_SPEC2_19_ForwardServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests_SPEC2_19_ForwardServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

28. DispatcherTests_SPEC2_19_IncludeServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests_SPEC2_19_IncludeServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests_SPEC2_19_IncludeServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

29. DispatcherTests2_SPEC2_19_ForwardJSPResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests2_SPEC2_19_ForwardJSPResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests2_SPEC2_19_ForwardJSPResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

30. DispatcherTests2_SPEC2_19_IncludeJSPResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests2_SPEC2_19_IncludeJSPResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests2_SPEC2_19_IncludeJSPResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

31. DispatcherTests3S_SPEC2_19_IncludeJSPResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests3S_SPEC2_19_IncludeJSPResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests3S_SPEC2_19_IncludeJSPResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

32. DispatcherTests3S_SPEC2_19_IncludeServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests3S_SPEC2_19_IncludeServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests3S_SPEC2_19_IncludeServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

33. DispatcherTests4_SPEC2_19_ForwardJSPResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests4_SPEC2_19_ForwardJSPResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests4_SPEC2_19_ForwardJSPResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

34. DispatcherTests4_SPEC2_19_ForwardServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests4_SPEC2_19_ForwardServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests4_SPEC2_19_ForwardServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

35. DispatcherTests4_SPEC2_19_IncludeJSPResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests4_SPEC2_19_IncludeJSPResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests4_SPEC2_19_IncludeJSPResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

36. DispatcherTests4_SPEC2_19_IncludeServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests4_SPEC2_19_IncludeServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests4_SPEC2_19_IncludeServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

37. DispatcherTests5_SPEC2_19_IncThenForwardServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests5_SPEC2_19_IncThenForwardServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests5_SPEC2_19_IncThenForwardServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

38. DispatcherTests5_SPEC2_19_IncThenIncludeServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests5_SPEC2_19_IncThenIncludeServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests5_SPEC2_19_IncThenIncludeServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

39. DispatcherTests6_SPEC2_19_FwdThenForwardServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests6_SPEC2_19_FwdThenForwardServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests6_SPEC2_19_FwdThenForwardServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

40. DispatcherTests6_SPEC2_19_FwdThenIncludeServletResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"DispatcherTests6_SPEC2_19_FwdThenIncludeServletResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"DispatcherTests6_SPEC2_19_FwdThenIncludeServletResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

41. PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr39#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(FULL);
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr39\">no resource output.</div>\n");
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr39\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

42. PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr40#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PORTLET);
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr40\">no resource output.</div>\n");
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"PortletTagLibraryTests3_SPEC2_26_IncludeJSPResource_tr40\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

43. RequestTests_ClientDataRequest_ApiResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet render entry");
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"RequestTests_ClientDataRequest_ApiResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"RequestTests_ClientDataRequest_ApiResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

44. ResponseTests_MimeResponse_ApiResource#render()

View license
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);
    PrintWriter writer = portletResp.getWriter();
    writer.write("<div id=\"ResponseTests_MimeResponse_ApiResource\">no resource output.</div>\n");
    ResourceURL resurl = portletResp.createResourceURL();
    resurl.setCacheability(ResourceURL.PAGE);
    writer.write("<script>\n");
    writer.write("(function () {\n");
    writer.write("   var xhr = new XMLHttpRequest();\n");
    writer.write("   xhr.onreadystatechange=function() {\n");
    writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
    writer.write("         document.getElementById(\"ResponseTests_MimeResponse_ApiResource\").innerHTML=xhr.responseText;\n");
    writer.write("      }\n");
    writer.write("   };\n");
    writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
    writer.write("   xhr.send();\n");
    writer.write("})();\n");
    writer.write("</script>\n");
}

45. TestProcessIndicators#generateTestFileHeadings()

View license
public void generateTestFileHeadings(boolean header) throws IOException {
    PrintWriter tw = new PrintWriter(new FileWriter(INPUT_NAME));
    if (header) {
        tw.println("date,close");
    }
    tw.println("20100101,1");
    tw.println("20100102,2");
    tw.println("20100103,3");
    tw.println("20100104,4");
    tw.println("20100105,5");
    tw.println("20100106,6");
    tw.println("20100107,7");
    tw.println("20100108,8");
    tw.println("20100109,9");
    tw.println("20100110,10");
    // close the stream
    tw.close();
}

46. ForrestController#doPost()

Project: forrest
Source File: ForrestController.java
View license
/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
    out.println("<HTML>");
    out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
    out.println("  <BODY>");
    out.print("    This is ");
    out.print(this.getClass());
    out.println(", using the POST method");
    out.println("  </BODY>");
    out.println("</HTML>");
    out.flush();
    out.close();
}

47. ResourceResolverWebConsolePlugin#doGet()

View license
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
    final String msg = request.getParameter(PAR_MSG);
    final String test;
    if (msg != null) {
        test = request.getParameter(PAR_TEST);
    } else {
        test = null;
    }
    final PrintWriter pw = response.getWriter();
    pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
    final MapEntries mapEntries = resolverFactory.getMapEntries();
    titleHtml(pw, "Configuration", null);
    pw.println("<tr class='content'>");
    pw.println("<td class='content'>Resource Search Path</td>");
    pw.print("<td class='content' colspan='2'>");
    pw.print(Arrays.asList(resolverFactory.getSearchPath()).toString());
    pw.print("</td>");
    pw.println("</tr>");
    pw.println("<tr class='content'>");
    pw.println("<td class='content'>Namespace Mangling</td>");
    pw.print("<td class='content' colspan='2'>");
    pw.print(resolverFactory.isMangleNamespacePrefixes() ? "Enabled" : "Disabled");
    pw.print("</td>");
    pw.println("</tr>");
    pw.println("<tr class='content'>");
    pw.println("<td class='content'>Mapping Location</td>");
    pw.print("<td class='content' colspan='2'>");
    pw.print(resolverFactory.getMapRoot());
    pw.print("</td>");
    pw.println("</tr>");
    separatorHtml(pw);
    titleHtml(pw, "Configuration Test", "To test the configuration, enter an URL or a resource path into " + "the field and click 'Resolve' to resolve the URL or click 'Map' " + "to map the resource path. To simulate a map call that takes the " + "current request into account, provide a full URL whose " + "scheme/host/port prefix will then be used as the request " + "information. The path passed to map will always be the path part " + "of the URL.");
    pw.println("<tr class='content'>");
    pw.println("<td class='content'>Test</td>");
    pw.print("<td class='content' colspan='2'>");
    pw.print("<form method='post'>");
    pw.print("<input type='text' name='" + ATTR_TEST + "' value='");
    if (test != null) {
        pw.print(ResponseUtil.escapeXml(test));
    }
    pw.println("' class='input' size='50'>");
    pw.println("  <input type='submit' name='" + ATTR_SUBMIT + "' value='Resolve' class='submit'>");
    pw.println("  <input type='submit' name='" + ATTR_SUBMIT + "' value='Map' class='submit'>");
    pw.print("</form>");
    pw.print("</td>");
    pw.println("</tr>");
    if (msg != null) {
        pw.println("<tr class='content'>");
        pw.println("<td class='content'> </td>");
        pw.print("<td class='content' colspan='2'>");
        pw.print(ResponseUtil.escapeXml(msg));
        pw.println("</td>");
        pw.println("</tr>");
    }
    separatorHtml(pw);
    dumpDTOsHtml(pw);
    separatorHtml(pw);
    dumpMapHtml(pw, "Resolver Map Entries", "Lists the entries used by the ResourceResolver.resolve methods to map URLs to Resources", mapEntries.getResolveMaps());
    separatorHtml(pw);
    dumpMapHtml(pw, "Mapping Map Entries", "Lists the entries used by the ResourceResolver.map methods to map Resource Paths to URLs", mapEntries.getMapMaps());
    pw.println("</table>");
}

48. GreetingWriter#writeTo()

Project: wink
Source File: GreetingWriter.java
View license
public void writeTo(Greeting t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
    PrintWriter out = new PrintWriter(entityStream);
    out.println("<html>");
    out.println("<body>");
    out.println("<h1>");
    out.print(t.getVerb());
    out.print(", ");
    out.print(t.getName() != null ? t.getName() : "unknown");
    out.print(".");
    out.println("</h1>");
    out.println("</body>");
    out.println("</html>");
    out.flush();
}

49. DropboxBrowse#renderFile()

Project: dropbox-sdk-java
Source File: DropboxBrowse.java
View license
private void renderFile(HttpServletResponse response, String path, FileMetadata f) throws IOException {
    FormProtection fp = FormProtection.start(response);
    response.setContentType("text/html");
    response.setCharacterEncoding("utf-8");
    PrintWriter out = new PrintWriter(IOUtil.utf8Writer(response.getOutputStream()));
    out.println("<html>");
    out.println("<head><title>" + escapeHtml4(path) + "- Web File Browser</title></head>");
    out.println("<body>");
    fp.insertAntiRedressHtml(out);
    out.println("<h2>Path: " + escapeHtml4(path) + "</h2>");
    out.println("<pre>");
    out.print(escapeHtml4(f.toStringMultiline()));
    out.println("</pre>");
    out.println("</body>");
    out.println("</html>");
    out.flush();
}

50. Loader#createIndexHtml()

Project: hmcScanner
Source File: Loader.java
View license
private void createIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + index_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + index_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n<TITLE>hmcScanner HTML</TITLE>");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + menu_html + "\" frameborder=\"0\" name=\"menu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" src=\"" + header_html + "\" frameborder=\"0\" name=\"data\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

51. Loader#createSystemPerfIndexHtml()

Project: hmcScanner
Source File: Loader.java
View license
private void createSystemPerfIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + sysperfindex_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + sysperfindex_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + sysperfmenu_html + "\" frameborder=\"0\" name=\"sysperfmenu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" frameborder=\"0\" name=\"sysperfdata\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

52. Loader#createPoolPerfIndexHtml()

Project: hmcScanner
Source File: Loader.java
View license
private void createPoolPerfIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + poolperfindex_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + poolperfindex_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + poolperfmenu_html + "\" frameborder=\"0\" name=\"sysperfmenu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" frameborder=\"0\" name=\"poolperfdata\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

53. Loader#createLPARPerfIndexHtml()

Project: hmcScanner
Source File: Loader.java
View license
private void createLPARPerfIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + lparperfindex_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + lparperfindex_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + lparperfmenu_html + "\" frameborder=\"0\" name=\"sysperfmenu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" frameborder=\"0\" name=\"lparperfdata\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

54. Old_Loader#createIndexHtml()

Project: hmcScanner
Source File: Old_Loader.java
View license
private void createIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + index_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + index_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n<TITLE>hmcScanner HTML</TITLE>");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + menu_html + "\" frameborder=\"0\" name=\"menu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" src=\"" + header_html + "\" frameborder=\"0\" name=\"data\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

55. Old_Loader#createSystemPerfIndexHtml()

Project: hmcScanner
Source File: Old_Loader.java
View license
private void createSystemPerfIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + sysperfindex_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + sysperfindex_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + sysperfmenu_html + "\" frameborder=\"0\" name=\"sysperfmenu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" frameborder=\"0\" name=\"sysperfdata\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

56. Old_Loader#createPoolPerfIndexHtml()

Project: hmcScanner
Source File: Old_Loader.java
View license
private void createPoolPerfIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + poolperfindex_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + poolperfindex_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + poolperfmenu_html + "\" frameborder=\"0\" name=\"sysperfmenu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" frameborder=\"0\" name=\"poolperfdata\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

57. Old_Loader#createLPARPerfIndexHtml()

Project: hmcScanner
Source File: Old_Loader.java
View license
private void createLPARPerfIndexHtml(String dirName) {
    PrintWriter index;
    try {
        index = new PrintWriter(new FileOutputStream(dirName + File.separatorChar + lparperfindex_html));
    } catch (IOException e) {
        System.out.println("\nError creating file " + dirName + File.separatorChar + lparperfindex_html);
        System.out.println("Skipping HTML creation");
        return;
    }
    // Create iframed index
    index.println("<HTML>\n<HEAD>\n");
    index.println("<style type=\"text/css\">");
    index.println("<!--\niframe {\nfloat:left;\nmargin:0px;\n}\n-->");
    index.println("</style>\n</head>");
    index.println("<BODY BCOLOR=#e6e6e6>");
    index.println("<iframe width=\"15%\" height=\"100%\" src=\"" + lparperfmenu_html + "\" frameborder=\"0\" name=\"sysperfmenu\"></iframe>");
    index.println("<iframe width=\"85%\" height=\"100%\" frameborder=\"0\" name=\"lparperfdata\"</iframe>");
    index.println("</BODY>");
    index.println("</HTML>");
    index.close();
}

58. LDAPExampleServlet#doGet()

Project: keycloak
Source File: LDAPExampleServlet.java
View license
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    KeycloakSecurityContext securityContext = (KeycloakSecurityContext) req.getAttribute(KeycloakSecurityContext.class.getName());
    IDToken idToken = securityContext.getIdToken();
    PrintWriter out = resp.getWriter();
    out.println("<html><head><title>LDAP Portal</title></head><body>");
    out.println("<table border><tr><th>Attribute name</th><th>Attribute values</th></tr>");
    out.printf("<tr><td>%s</td><td>%s</td></tr>", "preferred_username", idToken.getPreferredUsername());
    out.println();
    out.printf("<tr><td>%s</td><td>%s</td></tr>", "name", idToken.getName());
    out.println();
    out.printf("<tr><td>%s</td><td>%s</td></tr>", "email", idToken.getEmail());
    out.println();
    for (Map.Entry<String, Object> claim : idToken.getOtherClaims().entrySet()) {
        String value = claim.getValue().toString();
        out.printf("<tr><td>%s</td><td>%s</td></tr>", claim.getKey(), value);
        out.println();
    }
    out.println("</table></body></html>");
    out.flush();
}

59. TestMultiStorage#createFile()

Project: pig
Source File: TestMultiStorage.java
View license
private void createFile() throws IOException {
    PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE));
    w.println("100\tapple\taaa1");
    w.println("200\torange\tbbb1");
    w.println("300\tstrawberry\tccc1");
    w.println("101\tapple\taaa2");
    w.println("201\torange\tbbb2");
    w.println("301\tstrawberry\tccc2");
    w.println("102\tapple\taaa3");
    w.println("202\torange\tbbb3");
    w.println("302\tstrawberry\tccc3");
    w.close();
    Util.deleteFile(cluster, INPUT_FILE);
    Util.copyFromLocalToCluster(cluster, INPUT_FILE, INPUT_FILE);
}

60. TestCollectedGroup#createFiles()

Project: pig
Source File: TestCollectedGroup.java
View license
private void createFiles() throws IOException {
    PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE));
    w.println("100\tapple1\t95");
    w.println("100\tapple2\t83");
    w.println("100\tapple2\t74");
    w.println("200\torange1\t100");
    w.println("200\torange2\t89");
    w.println("300\tstrawberry\t64");
    w.println("300\tstrawberry\t64");
    w.println("300\tstrawberry\t76");
    w.println("400\tpear\t78");
    w.close();
    Util.copyFromLocalToCluster(cluster, INPUT_FILE, INPUT_FILE);
}

61. TestSkewedJoin#createFiles()

Project: pig
Source File: TestSkewedJoin.java
View license
private static void createFiles() throws IOException {
    new File(INPUT_DIR).mkdirs();
    new File(OUTPUT_DIR).mkdirs();
    PrintWriter w = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE1));
    int k = 0;
    for (int j = 0; j < 120; j++) {
        w.println("100\tapple1\taaa" + k);
        k++;
        w.println("200\torange1\tbbb" + k);
        k++;
        w.println("300\tstrawberry\tccc" + k);
        k++;
    }
    w.close();
    PrintWriter w2 = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE2));
    w2.println("100\tapple1");
    w2.println("100\tapple2");
    w2.println("100\tapple2");
    w2.println("200\torange1");
    w2.println("200\torange2");
    w2.println("300\tstrawberry");
    w2.println("400\tpear");
    w2.close();
    PrintWriter w3 = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE3));
    w3.println("100\tapple1");
    w3.println("100\tapple2");
    w3.println("200\torange1");
    w3.println("200\torange2");
    w3.println("300\tstrawberry");
    w3.println("300\tstrawberry2");
    w3.println("400\tpear");
    w3.close();
    PrintWriter w4 = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE4));
    for (int i = 0; i < 100; i++) {
        w4.println("[a100#apple1,a100#apple2,a200#orange1,a200#orange2,a300#strawberry,a300#strawberry2,a400#pear]");
    }
    w4.close();
    // Create a file with null keys
    PrintWriter w5 = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE5));
    for (int i = 0; i < 10; i++) {
        w5.println("\tapple1");
    }
    w5.println("100\tapple2");
    for (int i = 0; i < 10; i++) {
        w5.println("\torange1");
    }
    w5.println("\t");
    w5.println("100\t");
    w5.close();
    PrintWriter w6 = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE6));
    for (int i = 0; i < 300; i++) {
        for (int j = 0; j < 5; j++) {
            w6.println("" + i + "\t" + j);
        }
    }
    w6.close();
    PrintWriter w7 = new PrintWriter(new FileWriter(INPUT_DIR + "/" + INPUT_FILE7));
    for (int i = 0; i < 300; i = i + 3) {
        for (int j = 0; j < 2; j++) {
            w7.println("" + i + "\t" + j);
        }
    }
    w7.close();
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE1, INPUT_FILE1);
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE2, INPUT_FILE2);
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE3, INPUT_FILE3);
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE4, INPUT_FILE4);
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE5, INPUT_FILE5);
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE6, INPUT_FILE6);
    Util.copyFromLocalToCluster(cluster, INPUT_DIR + "/" + INPUT_FILE7, INPUT_FILE7);
}

62. OutputCatcher#writeTo()

Project: ThriftyPaxos
Source File: OutputCatcher.java
View license
/**
     * Write the output to a HTML file.
     *
     * @param title the title
     * @param fileName the file name
     */
public void writeTo(String title, String fileName) throws IOException {
    File file = new File(fileName);
    file.getParentFile().mkdirs();
    PrintWriter writer = new PrintWriter(new FileOutputStream(file));
    writer.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 " + "Strict//EN\" " + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
    writer.write("<html xmlns=\"http://www.w3.org/1999/xhtml\" " + "lang=\"en\" xml:lang=\"en\">\n");
    writer.write("<head><meta http-equiv=\"Content-Type\" " + "content=\"text/html;charset=utf-8\" /><title>\n");
    writer.print(title);
    writer.print("</title><link rel=\"stylesheet\" " + "type=\"text/css\" href=\"stylesheet.css\" />\n");
    writer.print("</head><body style=\"margin: 20px;\">\n");
    writer.print("<h1>" + title + "</h1><br />\n");
    writer.print(output);
    writer.write("\n</body></html>");
    writer.close();
}

63. HTTPSServerThread#sendResponse()

Project: bc-java
Source File: HTTPSServerThread.java
View license
/**
     * Send a response
     */
private void sendResponse(OutputStream out) {
    PrintWriter pWrt = new PrintWriter(new OutputStreamWriter(out));
    pWrt.print("HTTP/1.1 200 OK\r\n");
    pWrt.print("Content-Type: text/html\r\n");
    pWrt.print("\r\n");
    pWrt.print("<html>\r\n");
    pWrt.print("<body>\r\n");
    pWrt.print("Hello World!\r\n");
    pWrt.print("</body>\r\n");
    pWrt.print("</html>\r\n");
    pWrt.flush();
}

64. NewsHandler#handle()

Project: Launcher
Source File: NewsHandler.java
View license
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    response.setContentType("text/html; charset=utf-8");
    response.setStatus(HttpServletResponse.SC_OK);
    PrintWriter writer = response.getWriter();
    writer.write("<!DOCTYPE html>");
    writer.write("<html>");
    writer.write("<head>");
    writer.write("<title>Staging Tool</title>");
    writer.write("</head>");
    writer.write("<body>");
    writer.write("<p>Welcome to the staging tool!</p>");
    writer.write("</body>");
    writer.write("</html>");
    baseRequest.setHandled(true);
}

65. TestProxyGeneratorServlet#doGet()

View license
/**
     * DOCUMENT ME!
     *
     * @param request DOCUMENT ME!
     * @param response DOCUMENT ME!
     *
     * @throws IOException DOCUMENT ME!
     * @throws ServletException DOCUMENT ME!
     */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    response.setContentType("text/xml");
    PrintWriter writer = response.getWriter();
    writer.print("<?xml version=\"1.0\"?>");
    writer.print("<servlet class=\"" + this.getClass().getName() + "\">");
    writer.print("<request method=\"GET\">");
    writer.print(getRequestInfo(request));
    writer.print(getParameters(request));
    writer.print(getSession(request));
    writer.print(getCookies(request));
    writer.print("</request>");
    writer.print("</servlet>");
}

66. TestProxyGeneratorServlet#doPost()

View license
/**
     * DOCUMENT ME!
     *
     * @param request DOCUMENT ME!
     * @param response DOCUMENT ME!
     *
     * @throws ServletException DOCUMENT ME!
     * @throws IOException DOCUMENT ME!
     */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/xml");
    PrintWriter writer = response.getWriter();
    writer.print("<?xml version=\"1.0\"?>");
    writer.print("<servlet class=\"" + this.getClass().getName() + "\">");
    writer.print("<request method=\"POST\">");
    writer.print(getRequestInfo(request));
    writer.print(getParameters(request));
    writer.print(getSession(request));
    writer.print(getCookies(request));
    writer.print("</request>");
    writer.print("</servlet>");
}

67. HttpAdapter#writeNotFoundErrorPage()

Project: openjdk
Source File: HttpAdapter.java
View license
private void writeNotFoundErrorPage(WSHTTPConnection con, String message) throws IOException {
    con.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
    con.setContentTypeResponseHeader("text/html; charset=utf-8");
    PrintWriter out = new PrintWriter(new OutputStreamWriter(con.getOutput(), "UTF-8"));
    out.println("<html>");
    out.println("<head><title>");
    out.println(WsservletMessages.SERVLET_HTML_TITLE());
    out.println("</title></head>");
    out.println("<body>");
    out.println(WsservletMessages.SERVLET_HTML_NOT_FOUND(message));
    out.println("</body>");
    out.println("</html>");
    out.close();
}

68. HelloServlet#doGet()

Project: uadetector
Source File: HelloServlet.java
View license
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    response.setStatus(HttpServletResponse.SC_OK);
    PrintWriter out = response.getWriter();
    out.println("<h1>Hello Servlet</h1>");
    out.println("session=" + request.getSession(true).getId());
    out.println("<br>");
    out.println("<br>");
    // Get an UserAgentStringParser and analyze the requesting client
    UserAgentStringParser parser = UADetectorServiceFactory.getOnlineUpdatingParser();
    ReadableUserAgent agent = parser.parse(request.getHeader("User-Agent"));
    out.append("You're a <em>");
    out.append(agent.getName());
    out.append("</em> on <em>");
    out.append(agent.getOperatingSystem().getName());
    out.append("</em>!");
}

69. Common#page()

Project: dropbox-sdk-java
Source File: Common.java
View license
public void page(HttpServletResponse response, int statusCode, String title, String message) throws IOException {
    title = escapeHtml4(title);
    message = escapeHtml4(message);
    response.setContentType("text/html");
    response.setCharacterEncoding("utf-8");
    PrintWriter out = new PrintWriter(new OutputStreamWriter(response.getOutputStream(), "UTF-8"));
    out.println("<html>");
    out.println("<head><title>" + title + "</title></head>");
    out.println("<body>");
    out.println("<h2>" + title + "</h2>");
    out.println("<p>" + message + "</p>");
    out.println("</body>");
    out.println("</html>");
    out.flush();
    response.setStatus(statusCode);
}

70. Banner#getBanner()

Project: geronimo-gshell
Source File: Banner.java
View license
///CLOVER:OFF
public static String getBanner() {
    StringWriter writer = new StringWriter();
    PrintWriter out = new PrintWriter(writer);
    out.println("   ____ ____  _          _ _ ");
    out.println("  / ___/ ___|| |__   ___| | |");
    out.println(" | |  _\\___ \\| '_ \\ / _ \\ | |");
    out.println(" | |_| |___) | | | |  __/ | |");
    out.println("  \\____|____/|_| |_|\\___|_|_|");
    out.println();
    out.println(" GShell -- Geronimo command-line shell");
    out.flush();
    return writer.toString();
}

71. TestFairScheduler#testAllocationFileParsing()

View license
public void testAllocationFileParsing() throws Exception {
    PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
    out.println("<?xml version=\"1.0\"?>");
    out.println("<allocations>");
    // Give pool A a minimum of 1 map, 2 reduces
    out.println("<pool name=\"poolA\">");
    out.println("<minMaps>1</minMaps>");
    out.println("<minReduces>2</minReduces>");
    out.println("</pool>");
    // Give pool B a minimum of 2 maps, 1 reduce
    out.println("<pool name=\"poolB\">");
    out.println("<minMaps>2</minMaps>");
    out.println("<minReduces>1</minReduces>");
    out.println("</pool>");
    // Give pool C min maps but no min reduces
    out.println("<pool name=\"poolC\">");
    out.println("<minMaps>2</minMaps>");
    out.println("</pool>");
    // Give pool D a limit of 3 running jobs
    out.println("<pool name=\"poolD\">");
    out.println("<maxRunningJobs>3</maxRunningJobs>");
    out.println("</pool>");
    // Give pool E a preemption timeout of one minute
    out.println("<pool name=\"poolE\">");
    out.println("<minSharePreemptionTimeout>60</minSharePreemptionTimeout>");
    out.println("</pool>");
    // Set default limit of jobs per pool to 15
    out.println("<poolMaxJobsDefault>15</poolMaxJobsDefault>");
    // Set default limit of jobs per user to 5
    out.println("<userMaxJobsDefault>5</userMaxJobsDefault>");
    // Give user1 a limit of 10 jobs
    out.println("<user name=\"user1\">");
    out.println("<maxRunningJobs>10</maxRunningJobs>");
    out.println("</user>");
    // Set default min share preemption timeout to 2 minutes
    out.println("<defaultMinSharePreemptionTimeout>120" + "</defaultMinSharePreemptionTimeout>");
    // Set fair share preemption timeout to 5 minutes
    out.println("<fairSharePreemptionTimeout>300</fairSharePreemptionTimeout>");
    out.println("</allocations>");
    out.close();
    PoolManager poolManager = scheduler.getPoolManager();
    poolManager.reloadAllocs();
    // 5 in file + default pool
    assertEquals(6, poolManager.getPools().size());
    assertEquals(0, poolManager.getAllocation(Pool.DEFAULT_POOL_NAME, TaskType.MAP));
    assertEquals(0, poolManager.getAllocation(Pool.DEFAULT_POOL_NAME, TaskType.REDUCE));
    assertEquals(1, poolManager.getAllocation("poolA", TaskType.MAP));
    assertEquals(2, poolManager.getAllocation("poolA", TaskType.REDUCE));
    assertEquals(2, poolManager.getAllocation("poolB", TaskType.MAP));
    assertEquals(1, poolManager.getAllocation("poolB", TaskType.REDUCE));
    assertEquals(2, poolManager.getAllocation("poolC", TaskType.MAP));
    assertEquals(0, poolManager.getAllocation("poolC", TaskType.REDUCE));
    assertEquals(0, poolManager.getAllocation("poolD", TaskType.MAP));
    assertEquals(0, poolManager.getAllocation("poolD", TaskType.REDUCE));
    assertEquals(0, poolManager.getAllocation("poolE", TaskType.MAP));
    assertEquals(0, poolManager.getAllocation("poolE", TaskType.REDUCE));
    assertEquals(15, poolManager.getPoolMaxJobs(Pool.DEFAULT_POOL_NAME));
    assertEquals(15, poolManager.getPoolMaxJobs("poolA"));
    assertEquals(15, poolManager.getPoolMaxJobs("poolB"));
    assertEquals(15, poolManager.getPoolMaxJobs("poolC"));
    assertEquals(3, poolManager.getPoolMaxJobs("poolD"));
    assertEquals(15, poolManager.getPoolMaxJobs("poolE"));
    assertEquals(10, poolManager.getUserMaxJobs("user1"));
    assertEquals(5, poolManager.getUserMaxJobs("user2"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout(Pool.DEFAULT_POOL_NAME));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("poolA"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("poolB"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("poolC"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("poolD"));
    assertEquals(120000, poolManager.getMinSharePreemptionTimeout("poolA"));
    assertEquals(60000, poolManager.getMinSharePreemptionTimeout("poolE"));
    assertEquals(300000, poolManager.getFairSharePreemptionTimeout());
}

72. TestFileTailingAdaptorBigRecord#makeTestFile()

View license
private File makeTestFile(String name) throws IOException {
    File tmpOutput = new File(name);
    FileOutputStream fos = new FileOutputStream(tmpOutput);
    PrintWriter pw = new PrintWriter(fos);
    for (int i = 0; i < 5; ++i) {
        pw.print(i + " ");
        pw.println("abcdefghijklmnopqrstuvwxyz");
    }
    pw.print("6 ");
    for (int i = 0; i < 10; ++i) {
        pw.print("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
    }
    pw.print("\n");
    pw.print("7 ");
    pw.println("abcdefghijklmnopqrstuvwxyz");
    pw.print("8 ");
    pw.println("abcdefghijklmnopqrstuvwxyz");
    pw.flush();
    pw.close();
    return tmpOutput;
}

73. ARPTests#main()

Project: jena
Source File: ARPTests.java
View license
public static void main(String args[]) throws IOException {
    Test ts = suite();
    PrintWriter pw = new PrintWriter(new FileWriter("src/java/test/com/hp/hpl/jena/rdfxml/xmlinput/test/TestPackage.java"));
    pw.println("/*");
    pw.println(" * Licensed to the Apache Software Foundation (ASF) under one");
    pw.println(" * or more contributor license agreements.  See the NOTICE file");
    pw.println(" * distributed with this work for additional information");
    pw.println(" * regarding copyright ownership.  The ASF licenses this file");
    pw.println(" * to you under the Apache License, Version 2.0 (the");
    pw.println(" * \"License\"); you may not use this file except in compliance");
    pw.println(" * with the License.  You may obtain a copy of the License at");
    pw.println(" *");
    pw.println(" *     http://www.apache.org/licenses/LICENSE-2.0");
    pw.println(" *");
    pw.println(" * Unless required by applicable law or agreed to in writing, software");
    pw.println(" * distributed under the License is distributed on an \"AS IS\" BASIS,");
    pw.println(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    pw.println(" * See the License for the specific language governing permissions and");
    pw.println(" * limitations under the License.");
    pw.println(" */");
    pw.println();
    pw.println("package org.apache.jena.rdfxml.xmlinput.test;");
    pw.println("import junit.framework.TestSuite;");
    pw.println("import junit.framework.Test;");
    pw.println("import org.apache.jena.shared.wg.*;");
    pw.println("public class TestPackage{");
    pw.println("static public Test suite() {");
    String tsname = toJava(ts, pw, "xx");
    pw.println("return " + tsname + ";");
    pw.println("} }");
    pw.println("");
    pw.flush();
}

74. TimingTestCase#setUp()

Project: perf4j
Source File: TimingTestCase.java
View license
protected void setUp() throws Exception {
    testStopWatches = new ArrayList<StopWatch>();
    testStopWatches.add(new StopWatch(System.currentTimeMillis(), 1000L, "tag", "message1"));
    testStopWatches.add(new StopWatch(System.currentTimeMillis(), 2000L, "tag", "message2"));
    testStopWatches.add(new StopWatch(System.currentTimeMillis(), 3000L, "tag2", null));
    testStopWatches.add(new StopWatch(System.currentTimeMillis(), 4000L, "tag2", "message3"));
    testStopWatches.add(new StopWatch(System.currentTimeMillis() + 60000L, 5000L, "tag3", null));
    StringWriter testLogWriter;
    PrintWriter printWriter = new PrintWriter(testLogWriter = new StringWriter());
    printWriter.println(testStopWatches.get(0));
    printWriter.println(new Date() + " " + testStopWatches.get(1));
    printWriter.println("unrelated log message");
    printWriter.println(testStopWatches.get(2));
    printWriter.println("SomePrefixString " + testStopWatches.get(3));
    printWriter.println(testStopWatches.get(4));
    printWriter.println();
    printWriter.flush();
    testLog = testLogWriter.toString();
}

75. TestNumberOfReducers#verifySkewJoin()

Project: pig
Source File: TestNumberOfReducers.java
View license
/**
     * Specifying bytes_per_reducer, default_parallel and parallel, verifying
     * whether it uses the actual #reducers as actual_parallel.
     * 
     * Note the input file size is 555B.
     * 
     */
private void verifySkewJoin(int bytes_per_reducer, int default_parallel, int parallel, int actual_parallel) throws IOException {
    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    // the file is 555B
    w.println("SET pig.exec.reducers.bytes.per.reducer " + bytes_per_reducer + ";");
    w.println("SET default_parallel " + default_parallel + ";");
    w.println("A1 = load '" + HDFS_INPUT_FILE + "';");
    w.println("A2 = load '" + HDFS_INPUT_FILE + "';");
    w.print("B = join A1 by $0,  A2 by $0 using 'skewed' ");
    if (parallel > 0)
        w.print("parallel " + parallel);
    w.println(";");
    w.println("store B into '" + OUTPUT_FILE + "';");
    w.close();
    doTest(bytes_per_reducer, default_parallel, parallel, actual_parallel);
}

76. MimeTypeWebConsolePlugin#doGet()

Project: sling
Source File: MimeTypeWebConsolePlugin.java
View license
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    Map<String, Set<String>> mimetab = new TreeMap<String, Set<String>>();
    Map<String, String> extMap = mimeTypeService.getExtensionMap();
    int numExt = 0;
    for (Entry<String, String> entry : mimeTypeService.getMimeMap().entrySet()) {
        String ext = entry.getKey();
        String mime = entry.getValue();
        Set<String> extList = mimetab.get(mime);
        if (extList == null) {
            extList = new HashSet<String>();
            mimetab.put(mime, extList);
        }
        if (ext.equals(extMap.get(mime))) {
            ext = "*" + ext + "*";
        }
        extList.add(ext);
        numExt++;
    }
    PrintWriter pw = response.getWriter();
    pw.println("<script type='text/javascript' src='" + RES_LOC + "/jquery.treeTable.min.js'></script>");
    pw.println("<script type='text/javascript'>");
    pw.println("  $(document).ready(function()  {");
    pw.println("    $('#mimetabtable').treeTable({ treeColumn: 1 });");
    pw.println("  });");
    pw.println("</script>");
    pw.println("<div id='plugin_content'>");
    pw.println("<div class='fullwidth'>");
    pw.println("<div class='statusline'>Statistic: " + mimetab.size() + " MIME Types, " + numExt + " Extensions</div>");
    pw.println("</div>");
    pw.println("<div class='table'>");
    pw.println("<table id='mimetabtable' class='tablelayout'>");
    pw.println("<colgroup>");
    pw.println("<col width='20px'>");
    pw.println("<col width='50%'>");
    pw.println("<col width='50%'>");
    pw.println("</colgroup>");
    pw.println("<thead>");
    pw.println("<tr>");
    pw.println("<th colspan='2'>Mime Type</th>");
    pw.println("<th>Extensions</th>");
    pw.println("</tr>");
    pw.println("</thead>");
    pw.println("<tbody>");
    String currentMajor = null;
    for (Entry<String, Set<String>> entry : mimetab.entrySet()) {
        String major = getMajorType(entry.getKey());
        if (!major.equals(currentMajor)) {
            currentMajor = major;
            pw.println("<tr id='" + currentMajor + "'>");
            pw.println("<td> </td>");
            pw.println("<td>" + currentMajor + "</td>");
            pw.println("<td>--</td>");
            pw.println("</tr>");
        }
        pw.println("<tr id='" + entry.getKey().replace('/', '-') + "' class='child-of-" + currentMajor + "'>");
        pw.println("<td> </td>");
        pw.println("<td>" + entry.getKey() + "</td>");
        pw.println("<td>" + entry.getValue() + "</td>");
        pw.println("</tr>");
    }
    pw.println("</tbody>");
    pw.println("</table>");
    pw.println("</div>");
    pw.println("</div>");
}

77. YamlConfigurationTest#noColorConfig()

Project: tailor
Source File: YamlConfigurationTest.java
View license
private File noColorConfig(String fileName) throws IOException {
    File configFile = folder.newFile(fileName);
    Writer streamWriter = new OutputStreamWriter(new FileOutputStream(configFile), Charset.forName("UTF-8"));
    PrintWriter printWriter = new PrintWriter(streamWriter);
    printWriter.println("include:");
    printWriter.println("  - '**/" + YAML_TEST_1 + "'");
    printWriter.println("only:");
    printWriter.println("  - upper-camel-case");
    printWriter.println("except:");
    printWriter.println("  - terminating-semicolon");
    printWriter.println("color: disable");
    streamWriter.close();
    printWriter.close();
    return configFile;
}

78. BasicRelationship#toString()

Project: BotLibre
Source File: BasicRelationship.java
View license
public String toString() {
    StringWriter stringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(stringWriter);
    BasicVertex.writeHeader(getType(), writer);
    writer.print(" [");
    writer.print(getIndex());
    writer.print("] ");
    writer.print(" (");
    writer.print(((int) (getCorrectness() * 100)) / 100f);
    writer.print(")-> ");
    BasicVertex.writeHeader(getTarget(), writer);
    writer.flush();
    stringWriter.flush();
    return stringWriter.toString();
}

79. ManualGenerator#storeHTMLFile()

Project: camel
Source File: ManualGenerator.java
View license
private void storeHTMLFile(String content) throws IOException {
    String replaceToken = "<h3 id=\"replaceme\">.*</h3>";
    String replaceValue = "<h3>Version " + version + "</h3>";
    File outFile = new File(output);
    outFile.getParentFile().mkdirs();
    PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(outFile)));
    out.println("<html>");
    out.println("<head>");
    if (head != null) {
        out.println(head);
    }
    out.println("</head>");
    if (replaceToken != null && replaceValue != null) {
        content = content.replaceAll(replaceToken, replaceValue);
    }
    out.print("<body>");
    out.print(content);
    out.println("</body>");
    out.close();
}

80. TestBalanceCSV#generateTestFile()

Project: encog-java-core
Source File: TestBalanceCSV.java
View license
public void generateTestFile(boolean header) throws IOException {
    PrintWriter out = new PrintWriter(new FileWriter(INPUT_NAME));
    if (header) {
        out.println("a,b");
    }
    out.println("one,1");
    out.println("two,1");
    out.println("three,1");
    out.println("four,2");
    out.println("five,2");
    out.println("six,3");
    // close the stream
    out.close();
}

81. TestFilter#generateTestFileHeadings()

Project: encog-java-core
Source File: TestFilter.java
View license
public void generateTestFileHeadings(boolean header) throws IOException {
    PrintWriter tw = new PrintWriter(new FileWriter(INPUT_NAME));
    if (header) {
        tw.println("a,b");
    }
    tw.println("one,1");
    tw.println("two,1");
    tw.println("three,1");
    tw.println("four,2");
    tw.println("five,1");
    tw.println("six,1");
    // close the stream
    tw.close();
}

82. TestShuffle#generateTestFileHeadings()

Project: encog-java-core
Source File: TestShuffle.java
View license
public void generateTestFileHeadings(boolean header) throws IOException {
    PrintWriter tw = new PrintWriter(new FileWriter(INPUT_NAME));
    if (header) {
        tw.println("a,b");
    }
    tw.println("one,1");
    tw.println("two,2");
    tw.println("three,3");
    tw.println("four,4");
    tw.println("five,5");
    tw.println("six,6");
    // close the stream
    tw.close();
}

83. TestSort#generateTestFileHeadings()

Project: encog-java-core
Source File: TestSort.java
View license
public void generateTestFileHeadings(boolean header) throws IOException {
    PrintWriter tw = new PrintWriter(new FileWriter(INPUT_NAME));
    if (header) {
        tw.println("a,b");
    }
    tw.println("five,5");
    tw.println("four,4");
    tw.println("two,2");
    tw.println("three,3");
    tw.println("six,6");
    tw.println("one,1");
    // close the stream
    tw.close();
}

84. Aliasing6#doGet()

Project: JAADAS
Source File: Aliasing6.java
View license
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String[] names = req.getParameterValues(FIELD_NAME);
    Object o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15, o16, o17, o18, o19, o20, o21, o22, o23, o24, o25, o26, o27, o28, o29, o30, o31, o32, o33, o34, o35, o36, o37, o38, o39, o40;
    o1 = o2 = o3 = o4 = o5 = o6 = o7 = o8 = o9 = o10 = o11 = o12 = o13 = o14 = o15 = o16 = o17 = o18 = o19 = o20 = o21 = o22 = o23 = o24 = o25 = o26 = o27 = o28 = o29 = o30 = o31 = o32 = o33 = o34 = o35 = o36 = o37 = o38 = o39 = o40 = names[0];
    PrintWriter writer = resp.getWriter();
    writer.println(o1);
    /* BAD */
    writer.println(o2);
    /* BAD */
    writer.println(o3);
    /* BAD */
    writer.println(o4);
    /* BAD */
    writer.println(o32);
    /* BAD */
    writer.println(o37);
    /* BAD */
    writer.println(o40);
/* BAD */
}

85. Response#send()

Project: LGame
Source File: Response.java
View license
public void send() throws IOException {
    PrintWriter out = new PrintWriter(socket.getOutputStream());
    out.println(response);
    for (String line : header) {
        out.println(line);
    }
    out.println("Content-type: " + contentType + ";charset=" + charset);
    out.println("Content-length: " + body.length());
    out.println();
    out.print(body);
    out.flush();
    out.close();
}

86. HttpResponseImpl#createForbidden()

Project: openejb
Source File: HttpResponseImpl.java
View license
/** Creates a forbidden response to be sent to the browser using IP authentication
     * @param ip the ip that is forbidden
     * @return the HttpResponseImpl that this error belongs to
     */
protected static HttpResponseImpl createForbidden(String ip) {
    HttpResponseImpl res = new HttpResponseImpl(403, "Forbidden", "text/html");
    PrintWriter body = res.getPrintWriter();
    body.println("<html>");
    body.println("<body>");
    body.println("<h3>Forbidden</h3>");
    body.println("<br><br>");
    // Add more text here
    // IP not allowed, etc.
    body.println("IP address: " + ip + " is not registered on this server, please contact your system administrator.");
    body.println("</body>");
    body.println("</html>");
    return res;
}

87. HttpResponseImpl#createForbidden()

Project: openejb
Source File: HttpResponseImpl.java
View license
/** Creates a forbidden response to be sent to the browser using IP authentication
     * @param ip the ip that is forbidden
     * @return the HttpResponseImpl that this error belongs to
     */
protected static HttpResponseImpl createForbidden(String ip) {
    HttpResponseImpl res = new HttpResponseImpl(403, "Forbidden", "text/html");
    java.io.PrintWriter body = res.getPrintWriter();
    body.println("<html>");
    body.println("<body>");
    body.println("<h3>Forbidden</h3>");
    body.println("<br><br>");
    // Add more text here
    // IP not allowed, etc.
    body.println("IP address: " + ip + " is not registered on this server, please contact your system administrator.");
    body.println("</body>");
    body.println("</html>");
    return res;
}

88. TestNumberOfReducers#verifyOrderBy()

Project: pig
Source File: TestNumberOfReducers.java
View license
/**
     * Specifying bytes_per_reducer, default_parallel and parallel, verifying
     * whether it uses the actual #reducers as actual_parallel.
     * 
     * Note the input file size is 555B.
     * 
     */
private void verifyOrderBy(int bytes_per_reducer, int default_parallel, int parallel, int actual_parallel) throws IOException {
    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    // the file is 555B
    w.println("SET pig.exec.reducers.bytes.per.reducer " + bytes_per_reducer + ";");
    w.println("SET default_parallel " + default_parallel + ";");
    w.println("A = load '" + HDFS_INPUT_FILE + "';");
    w.print("B = order A by $0 ");
    if (parallel > 0)
        w.print("parallel " + parallel);
    w.println(";");
    w.println("store B into '" + OUTPUT_FILE + "';");
    w.close();
    doTest(bytes_per_reducer, default_parallel, parallel, actual_parallel);
}

89. SlingInfoServlet#renderHtml()

Project: sling
Source File: SlingInfoServlet.java
View license
private void renderHtml(SlingHttpServletResponse response, Map<String, String> data) throws IOException {
    // render data in JSON format
    response.setContentType("text/html");
    response.setCharacterEncoding("UTF-8");
    final PrintWriter out = response.getWriter();
    out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
    out.println("<html><head><title>Sling Info</title></head>");
    out.println("<body><h1>Sling Info</h1>");
    out.println("<table>");
    for (Map.Entry<String, String> e : data.entrySet()) {
        out.print("<tr><td>");
        out.print(e.getKey());
        out.print("</td><td>");
        out.print(e.getValue());
        out.println("</td></tr>");
    }
    out.println("</table>");
    out.println("</body>");
    out.flush();
}

90. YamlConfigurationTest#onlyAndExceptPrecedenceConfig()

Project: tailor
Source File: YamlConfigurationTest.java
View license
private File onlyAndExceptPrecedenceConfig(String fileName) throws IOException {
    File configFile = folder.newFile(fileName);
    Writer streamWriter = new OutputStreamWriter(new FileOutputStream(configFile), Charset.forName("UTF-8"));
    PrintWriter printWriter = new PrintWriter(streamWriter);
    printWriter.println("include:");
    printWriter.println("  - '**/" + YAML_TEST_1 + "'");
    printWriter.println("only:");
    printWriter.println("  - upper-camel-case");
    printWriter.println("except:");
    printWriter.println("  - terminating-semicolon");
    streamWriter.close();
    printWriter.close();
    return configFile;
}

91. HelloWorld#handle()

Project: uadetector
Source File: HelloWorld.java
View license
@Override
public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
    response.setContentType("text/html;charset=utf-8");
    response.setStatus(HttpServletResponse.SC_OK);
    baseRequest.setHandled(true);
    PrintWriter out = response.getWriter();
    out.println("<h1>Hello Servlet</h1>");
    out.println("<br>");
    // Get an UserAgentStringParser and analyze the requesting client
    UserAgentStringParser parser = UADetectorServiceFactory.getOnlineUpdatingParser();
    ReadableUserAgent agent = parser.parse(request.getHeader("User-Agent"));
    out.append("You're a <em>");
    out.append(agent.getName());
    out.append("</em> on <em>");
    out.append(agent.getOperatingSystem().getName());
    out.append("</em>!");
}

92. QueryElevationComponentTest#writeFile()

View license
// write a test file to boost some docs
private void writeFile(File file, String query, String... ids) throws Exception {
    PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
    out.println("<elevate>");
    out.println("<query text=\"" + query + "\">");
    for (String id : ids) {
        out.println(" <doc id=\"" + id + "\"/>");
    }
    out.println("</query>");
    out.println("</elevate>");
    out.flush();
    out.close();
    log.info("OUT:" + file.getAbsolutePath());
}

93. ClassDefItem#debugPrint()

Project: buck
Source File: ClassDefItem.java
View license
/**
     * Prints out the contents of this instance, in a debugging-friendly
     * way.
     *
     * @param out {@code non-null;} where to output to
     * @param verbose whether to be verbose with the output
     */
public void debugPrint(Writer out, boolean verbose) {
    PrintWriter pw = Writers.printWriterFor(out);
    pw.println(getClass().getName() + " {");
    pw.println("  accessFlags: " + Hex.u2(accessFlags));
    pw.println("  superclass: " + superclass);
    pw.println("  interfaces: " + ((interfaces == null) ? "<none>" : interfaces));
    pw.println("  sourceFile: " + ((sourceFile == null) ? "<none>" : sourceFile.toQuoted()));
    classData.debugPrint(out, verbose);
    annotationsDirectory.debugPrint(pw);
    pw.println("}");
}

94. RVFDataset#toSummaryString()

Project: CoreNLP
Source File: RVFDataset.java
View license
public String toSummaryString() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    pw.println("Number of data points: " + size());
    pw.print("Number of labels: " + labelIndex.size() + " [");
    Iterator<L> iter = labelIndex.iterator();
    while (iter.hasNext()) {
        pw.print(iter.next());
        if (iter.hasNext()) {
            pw.print(", ");
        }
    }
    pw.println("]");
    pw.println("Number of features (Phi(X) types): " + featureIndex.size());
    pw.println("Number of active feature types: " + numFeatureTypes());
    pw.println("Number of active feature tokens: " + numFeatureTokens());
    return sw.toString();
}

95. UserController#uploadPreviewImage()

Project: Cynthia
Source File: UserController.java
View license
/**
	 * @description:update the user pic
	 * @date:2014-5-5 ??8:46:09
	 * @version:v1.0
	 * @param request
	 * @param response
	 * @param session
	 * @return
	 * @throws IOException
	 */
@RequestMapping("/uploadPic.do")
@ResponseBody
public ModelAndView uploadPreviewImage(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException {
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    MultipartFile image = multipartRequest.getFile("userPic");
    response.setCharacterEncoding("UTF-8");
    response.setHeader("ContentType", "json");
    PrintWriter out = response.getWriter();
    String imgBase64 = ImageManager.getImageStr(image.getInputStream());
    //????base64?????????
    out.print("{");
    out.print("imgBase64:'" + JSONArray.toJSONString(imgBase64) + "',");
    out.print("msg:'success'");
    out.print("}");
    out.flush();
    out.close();
    return null;
}

96. ClassDefItem#debugPrint()

Project: dexmaker
Source File: ClassDefItem.java
View license
/**
     * Prints out the contents of this instance, in a debugging-friendly
     * way.
     *
     * @param out {@code non-null;} where to output to
     * @param verbose whether to be verbose with the output
     */
public void debugPrint(Writer out, boolean verbose) {
    PrintWriter pw = Writers.printWriterFor(out);
    pw.println(getClass().getName() + " {");
    pw.println("  accessFlags: " + Hex.u2(accessFlags));
    pw.println("  superclass: " + superclass);
    pw.println("  interfaces: " + ((interfaces == null) ? "<none>" : interfaces));
    pw.println("  sourceFile: " + ((sourceFile == null) ? "<none>" : sourceFile.toQuoted()));
    classData.debugPrint(out, verbose);
    annotationsDirectory.debugPrint(pw);
    pw.println("}");
}

97. StructOffsetResolver#generateFileForFramework()

Project: jdk7u-jdk
Source File: StructOffsetResolver.java
View license
/**
     * Generates Objective-C file and returns absolute path name.
     */
private String generateFileForFramework(Framework fw, Width arch) throws Exception {
    File tempfile = File.createTempFile("JObjC-SOR-" + fw.name + "-" + arch + "-", ".mm");
    PrintWriter out = new PrintWriter(new FileWriter(tempfile));
    out.println("#include<iostream>");
    printHeaderLines(fw, arch, out);
    out.println("");
    out.println("int main(int argc, char** argv){");
    printStructInfos(fw, arch, out);
    out.println("\treturn 0;");
    out.println("}");
    out.close();
    return tempfile.getAbsolutePath();
}

98. InputServlet#doGet()

Project: keycloak
Source File: InputServlet.java
View license
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String appBase;
    if (System.getProperty("app.server.ssl.required", "false").equals("true")) {
        appBase = System.getProperty("app.server.ssl.base.url", "https://localhost:8643");
    } else {
        appBase = System.getProperty("app.server.base.url", "http://localhost:8280");
    }
    String actionUrl = appBase + "/input-portal/secured/post";
    resp.setContentType("text/html");
    PrintWriter pw = resp.getWriter();
    pw.printf("<html><head><title>%s</title></head><body>", "Input Page");
    pw.printf("<form action=\"%s\" method=\"POST\">", actionUrl);
    pw.println("<input id=\"parameter\" type=\"text\" name=\"parameter\">");
    pw.println("<input name=\"submit\" type=\"submit\" value=\"Submit\"></form>");
    pw.print("</body></html>");
    pw.flush();
}

99. TestPigRunner#setUpBeforeClass()

Project: pig
Source File: TestPigRunner.java
View license
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    cluster = MiniGenericCluster.buildCluster();
    execType = cluster.getExecType().name().toLowerCase();
    PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE));
    w.println("1\t2\t3");
    w.println("5\t3\t4");
    w.println("3\t4\t5");
    w.println("5\t6\t7");
    w.println("3\t7\t8");
    w.close();
    Util.copyFromLocalToCluster(cluster, INPUT_FILE, INPUT_FILE);
}

100. TestPigRunner#returnCodeTest()

Project: pig
Source File: TestPigRunner.java
View license
@Test
public void returnCodeTest() throws Exception {
    PrintWriter w = new PrintWriter(new FileWriter(PIG_FILE));
    w.println("A = load 'non-existine.file' as (a0:int, a1:int, a2:int);");
    w.println("B = filter A by a0 > 0;;");
    w.println("C = group B by $0;");
    w.println("D = join C by $0, B by $0;");
    w.println("store D into '" + OUTPUT_FILE + "';");
    w.close();
    try {
        String[] args = { "-x", execType, PIG_FILE };
        PigStats stats = PigRunner.run(args, null);
        assertTrue(!stats.isSuccessful());
        assertTrue(stats.getReturnCode() != 0);
        assertTrue(stats.getOutputStats().size() == 0);
    } finally {
        new File(PIG_FILE).delete();
        Util.deleteFile(cluster, OUTPUT_FILE);
    }
}