Example usage for java.io PrintStream print

List of usage examples for java.io PrintStream print

Introduction

In this page you can find the example usage for java.io PrintStream print.

Prototype

public void print(Object obj) 

Source Link

Document

Prints an object.

Usage

From source file:com.oltpbenchmark.util.ResultUploader.java

public void writeDBParameters(PrintStream os) {
    String dbConf = collector.collectParameters();
    os.print(dbConf);
}

From source file:org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.java

public static void dumpSystemInfo(PrintStream out) {
    Properties p = System.getProperties();
    if (Platform.isRunning()) {
        p.put("build.system", Platform.getOS() + "-" + Platform.getOSArch() + "-" + Platform.getWS());
    } else {/* w  ww.  j a v  a 2  s  .c o  m*/
        p.put("build.system", "standalone");
    }
    String info = "System: ${os.name} ${os.version} (${os.arch}) / ${build.system} / ${java.vendor} ${java.vm.name} ${java.version}";
    for (Entry<Object, Object> entry : p.entrySet()) {
        info = info.replaceFirst(Pattern.quote("${" + entry.getKey() + "}"), entry.getValue().toString());
    }
    out.println(info);
    out.print("HTTP Proxy : " + WebUtil.getProxyForUrl("http://mylyn.org") + " (Platform)");
    try {
        out.print(" / " + ProxySelector.getDefault().select(new URI("http://mylyn.org")) + " (Java)");
    } catch (URISyntaxException e) {
        // ignore
    }
    out.println();
    out.print("HTTPS Proxy : " + WebUtil.getProxyForUrl("https://mylyn.org") + " (Platform)");
    try {
        out.print(" / " + ProxySelector.getDefault().select(new URI("https://mylyn.org")) + " (Java)");
    } catch (URISyntaxException e) {
        // ignore
    }
    out.println();
    out.println();
}

From source file:eu.europa.ec.fisheries.uvms.plugins.inmarsat.twostage.Connect.java

private void sendPsw(PrintStream output, String psw) throws IOException {
    output.print(psw + "\r\n");
    output.flush();// w ww .j  a  v  a  2 s  .c  om
    LOG.info("Sent psw");
}

From source file:com.mtnfog.idyl.e3.sdk.IdylE3StreamingClient.java

@Override
public EntityExtractionResponse stream(final String text) throws IOException {

    if (socket.isClosed()) {
        throw new IllegalStateException("The socket is closed.");
    }// ww  w .j  a  va 2  s.c om

    PrintStream out = new PrintStream(socket.getOutputStream());
    BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

    out.print(text);

    String json = in.readLine();

    System.out.println(json);

    in.close();
    out.close();

    return gson.fromJson(json, EntityExtractionResponse.class);

}

From source file:com.adaptris.core.fs.AggregatingFsConsumeServiceTest.java

private void writeDataMessage(File file) throws Exception {
    PrintStream out = null;
    try {//from  w  w  w . j av  a  2  s  .co m
        out = new PrintStream(new FileOutputStream(file), true);
        out.print(DATA_PAYLOAD);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:com.wandrell.example.swss.client.console.ConsoleClient.java

/**
 * Runs the main application loop./*from  w  w  w .ja  v a  2s . com*/
 * <p>
 * This is what keeps the client running and living. It can be stopped by
 * the user through a specific console command.
 *
 * @param output
 *            output where all the information will be printed
 * @param clients
 *            an {@code EntityClient} instance for each security method
 * @param uris
 *            an endpoint URI for each security method
 */
private static final void runMainLoop(final PrintStream output, final Map<Security, EntityClient> clients,
        final Map<Security, String> uris) {
    final Scanner scanner; // Scanner for reading the input
    Security security; // Selected security method
    EntityClient client; // Client for the selected security
    String uri; // Endpoint for the selected security
    String command; // Current user command

    scanner = new Scanner(System.in, "UTF-8");
    // The main loop
    // Stops when the 'exit' command is received
    do {
        // Prints options
        output.println();
        printClientOptions(output);
        output.println();

        // Reads command
        output.print("Pick an option: ");
        command = scanner.next();
        output.println();

        // Loads security from the command
        switch (command) {
        case "1":
            security = Security.UNSECURE;
            break;
        case "2":
            security = Security.PASSWORD_PLAIN_XWSS;
            break;
        case "3":
            security = Security.PASSWORD_PLAIN_WSS4J;
            break;
        case "4":
            security = Security.PASSWORD_DIGEST_XWSS;
            break;
        case "5":
            security = Security.PASSWORD_DIGEST_WSS4J;
            break;
        case "6":
            security = Security.SIGNATURE_XWSS;
            break;
        case "7":
            security = Security.SIGNATURE_WSS4J;
            break;
        case "8":
            security = Security.ENCRYPTION_XWSS;
            break;
        case "9":
            security = Security.ENCRYPTION_WSS4J;
            break;
        default:
            security = null;
            break;
        }

        // Checks if it was a valid option
        if (security != null) {
            // Valid option
            // The client and URI are acquired
            client = clients.get(security);
            uri = uris.get(security);

            // The endpoint is queried
            printQueryHeader(uri, security, output);
            callEndpoint(client, uri, output, scanner);
        }
    } while (!"exit".equalsIgnoreCase(command));

    scanner.close();
}

From source file:com.izforge.izpack.compiler.packager.impl.AbstractPackagerTest.java

/**
 * Helper to create a temporary text file containing the specified text.
 *
 * @param text the text//  w ww  . j a va  2  s  .  com
 * @return the new file
 * @throws IOException for any I/O error
 */
private File createTextFile(String text) throws IOException {
    File file = File.createTempFile("data", ".txt");
    PrintStream printStream = new PrintStream(file);
    printStream.print(text);
    printStream.close();
    return file;
}

From source file:avantssar.aslanpp.testing.TranslationInstance.java

private void filesCompared(PrintStream out, File f, File ref, String label, boolean odd) {
    out.print("<td");
    boolean different = false;
    if (f != null && ref != null) {
        try {/* w  w  w . j  a  v a  2 s  .co m*/
            different = !FileUtils.contentEquals(f, ref);
            out.print(" style='background-color: ");
            if (different) {
                out.print(TranslationReport.RED(odd));
            } else {
                out.print(TranslationReport.GREEN(odd));
            }
            out.print(";'");
        } catch (IOException e) {
            Debug.logger.error("Failed to compare files '" + f.getAbsolutePath() + "' and '"
                    + ref.getAbsolutePath() + "'.", e);
        }
    }
    out.print(">");
    HTMLHelper.fileOrDash(out, outputDir, f, null);
    if (ref != null && different) {
        out.print(" ");
        HTMLHelper.fileOrDash(out, outputDir, ref, label);
    }
    out.println("</td>");
}

From source file:net.sf.taverna.raven.helloworld.HelloWorld.java

public void run(PrintStream out) throws IOException {
    File tmpFile = File.createTempFile("helloworld", "test");
    tmpFile.deleteOnExit();/*from w ww . j av  a2  s. co  m*/
    FileUtils.writeStringToFile(tmpFile, TEST_DATA, "utf8");
    String read = FileUtils.readFileToString(tmpFile, "utf8");
    out.print(read);
}

From source file:com.adaptris.http.HttpRequest.java

/** Write the request line to the supplied outputstream.
 *  @param out the outputstream/*from w  w w .  j av a  2s .  co  m*/
 *  @throws HttpException on error.
 *  @see DataTransfer#writeTo(OutputStream)
 */
public void writeTo(OutputStream out) throws HttpException {
    try {
        logR.trace("Writing Request:- " + toString());
        PrintStream p = new PrintStream(out);
        p.print(toString());
        p.print(Http.CRLF);
        p.flush();
    } catch (Exception e) {
        throw new HttpException(e);
    }
}