Package java.io

Examples of java.io.PrintWriter


        // TODO use the right package
        ProxyCodeGenerator cg = new ProxyCodeGenerator();
        cg.setPackageName("bytecode");
        cg.generateClassProxy(c);
        StringWriter sw = new StringWriter();
        cg.write(new PrintWriter(sw));
        String code = sw.toString();
        String proxy = "bytecode."+ c.getSimpleName() + "Proxy";
        compiler.setSource(proxy, code);
        // System.out.println(code);
        Class<?> px = compiler.getClass(proxy);
View Full Code Here


    }

    private void testDataSource() throws SQLException {
        deleteDb("dataSource");
        JdbcDataSource ds = new JdbcDataSource();
        PrintWriter p = new PrintWriter(new StringWriter());
        ds.setLogWriter(p);
        assertTrue(p == ds.getLogWriter());
        ds.setURL(getURL("dataSource", true));
        ds.setUser(getUser());
        ds.setPassword(getPassword());
View Full Code Here

        }
    }

    private static boolean testConsistency() {
        FileOutputStream out = null;
        PrintWriter p = null;
        try {
            out = new FileOutputStream(TEST_DIRECTORY + "/result.txt");
            p = new PrintWriter(out);
            p.println("Results");
            p.flush();
        } catch (Throwable t) {
            t.printStackTrace();
            System.exit(0);
        }
        Connection conn = null;
        try {
            conn = openConnection();
            test(conn, "");
            test(conn, "ORDER BY D");
            closeConnection(conn);
            return true;
        } catch (Throwable t) {
            t.printStackTrace();
            t.printStackTrace(p);
            return false;
        } finally {
            if (conn != null) {
                try {
                    closeConnection(conn);
                } catch (Throwable t2) {
                    t2.printStackTrace();
                    t2.printStackTrace(p);
                }
            }
            p.flush();
            p.close();
            IOUtils.closeSilently(out);
        }
    }
View Full Code Here

     * @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();
    }
View Full Code Here

    private void testShutdown() throws SQLException {
        String url = getURL("connectionPool2", true), user = getUser(), password = getPassword();
        JdbcConnectionPool cp = JdbcConnectionPool.create(url, user, password);
        StringWriter w = new StringWriter();
        cp.setLogWriter(new PrintWriter(w));
        Connection conn1 = cp.getConnection();
        Connection conn2 = cp.getConnection();
        conn1.close();
        conn2.createStatement().execute("shutdown immediately");
        cp.dispose();
View Full Code Here

        assertEquals(1, man.getLoginTimeout());
        man.setLoginTimeout(0);
        assertEquals(30, man.getLoginTimeout());
        assertEquals(10, man.getMaxConnections());

        PrintWriter old = man.getLogWriter();
        PrintWriter pw = new PrintWriter(new StringWriter());
        man.setLogWriter(pw);
        assertTrue(pw == man.getLogWriter());
        man.setLogWriter(old);

        Connection conn1 = man.getConnection();
View Full Code Here

  Report report = new Report();
  report.setDatabaseConnection(conn);

  OUT_FILE.deleteOnExit();
  PrintWriter out = new PrintWriter(new FileWriter(OUT_FILE));
  report.setLayoutEngine(new CharSepLE(out, '\t'));

  report.runReport();
    }
    catch (Exception e) {
View Full Code Here

        }
        ArrayList<Object[]> results = dbs.get(0).getResults();
        Connection conn = null;
        PreparedStatement prep = null;
        Statement stat = null;
        PrintWriter writer = null;
        try {
            openResults();
            conn = getResultConnection();
            stat = conn.createStatement();
            prep = conn
                    .prepareStatement("INSERT INTO RESULTS(TESTID, TEST, UNIT, DBID, DB, RESULT) VALUES(?, ?, ?, ?, ?, ?)");
            for (int i = 0; i < results.size(); i++) {
                Object[] res = results.get(i);
                prep.setInt(1, i);
                prep.setString(2, res[0].toString());
                prep.setString(3, res[1].toString());
                for (Database db : dbs) {
                    prep.setInt(4, db.getId());
                    prep.setString(5, db.getName());
                    Object[] v = db.getResults().get(i);
                    prep.setString(6, v[2].toString());
                    prep.execute();
                }
            }

            writer = new PrintWriter(new FileWriter(out));
            ResultSet rs = stat.executeQuery(
                    "CALL '<table><tr><th>Test Case</th><th>Unit</th>' "
                    +"|| SELECT GROUP_CONCAT('<th>' || DB || '</th>' ORDER BY DBID SEPARATOR '') FROM "
                    +"(SELECT DISTINCT DBID, DB FROM RESULTS)"
                    +"|| '</tr>' || CHAR(10) "
                    +"|| SELECT GROUP_CONCAT('<tr><td>' || TEST || '</td><td>' || UNIT || '</td>' || ( "
                    +"SELECT GROUP_CONCAT('<td>' || RESULT || '</td>' ORDER BY DBID SEPARATOR '') FROM RESULTS R2 WHERE "
                    +"R2.TESTID = R1.TESTID) || '</tr>' ORDER BY TESTID SEPARATOR CHAR(10)) FROM "
                    +"(SELECT DISTINCT TESTID, TEST, UNIT FROM RESULTS) R1"
                    +"|| '</table>'"
            );
            rs.next();
            String result = rs.getString(1);
            writer.println(result);
        } finally {
            JdbcUtils.closeSilently(prep);
            JdbcUtils.closeSilently(stat);
            JdbcUtils.closeSilently(conn);
            IOUtils.closeSilently(writer);
View Full Code Here

        context.getTemplateDirectory());
    incl_tmpl.setLoaderContext(context);

    // If the included section has modifiers applied, we buffer it into a
    // string so that we can apply the modifiers.
    PrintWriter previous_printwriter = null;
    StringWriter sw = null;
    if (modifiers.size() > 0) {
      previous_printwriter = collector;
      sw = new StringWriter();
      collector = new PrintWriter(sw);
    }

    List<TemplateDictionary> child_dicts = dict.getChildDicts(includeName);
    if (child_dicts.size() == 0) {
      incl_tmpl.render(dict, collector);
View Full Code Here

    String var_name = edn.getVariableName();

    Range range = edn.advise(list, define_node_idx);
    List<TemplateNode> view = list.subList(range.getStart(), range.getStop());
    StringWriter sw = new StringWriter();
    render(view, td, new PrintWriter(sw));

    String new_value = sw.toString();
    td.put(var_name, new_value);

    return range.getSkipTo();
View Full Code Here

TOP

Related Classes of java.io.PrintWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.