Example usage for java.io PrintStream flush

List of usage examples for java.io PrintStream flush

Introduction

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

Prototype

public void flush() 

Source Link

Document

Flushes the stream.

Usage

From source file:org.owasp.goatdroid.gui.emulator.Emulator.java

static public void callEmulator(String phoneNumber) throws SocketException, IOException {

    TelnetClient telnet = new TelnetClient();
    telnet.setDefaultPort(5554);//from  www .  j av  a 2s  .co  m
    telnet.connect("localhost");
    PrintStream outStream = new PrintStream(telnet.getOutputStream());
    outStream.println("gsm call " + phoneNumber);
    outStream.flush();

}

From source file:Main.java

private static void destroyPid(int pid) {

    Process suProcess = null;//from   w w w  . j  av  a 2s  .c  o  m
    PrintStream outputStream = null;
    try {
        suProcess = Runtime.getRuntime().exec("su");
        outputStream = new PrintStream(new BufferedOutputStream(suProcess.getOutputStream(), 8192));
        outputStream.println("kill " + pid);
        outputStream.println("exit");
        outputStream.flush();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (outputStream != null) {
            outputStream.close();
        }
        if (suProcess != null) {
            try {
                suProcess.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:org.owasp.goatdroid.gui.emulator.Emulator.java

static public void sendSMSToEmulator(String phoneNumber, String message) throws SocketException, IOException {

    TelnetClient telnet = new TelnetClient();
    telnet.setDefaultPort(5554);/*  w  w w.jav  a2  s . c  o m*/
    telnet.connect("localhost");
    PrintStream outStream = new PrintStream(telnet.getOutputStream());
    outStream.println("sms send " + phoneNumber + " " + message);
    outStream.flush();

}

From source file:org.apache.openejb.assembler.classic.cmd.Info2Properties.java

private static void println(final PrintStream out, final String cr, final String text) {
    out.print(text.replace("\n", cr) + cr);
    out.flush();
}

From source file:com.splunk.shuttl.testutil.TUtilsFile.java

/**
 * Writes random alphanumeric content to specified file.
 * //from  w ww .  j  a v  a2  s. com
 * @param file
 */
public static void populateFileWithRandomContent(File file) {
    PrintStream printStream = null;
    try {
        printStream = new PrintStream(file);
        printStream.println(RandomStringUtils.randomAlphanumeric(1000));
        printStream.flush();
    } catch (FileNotFoundException e) {
        TUtilsTestNG.failForException("Failed to write random content", e);
    } finally {
        IOUtils.closeQuietly(printStream);
    }
}

From source file:edu.dfci.cccb.mev.analysis.Limma.java

private static void configureRows(OutputStream configuration, Heatmap heatmap, String s1, String s2)
        throws IOException {
    int rows = heatmap.getSummary().rows();
    MatrixSelection first = heatmap.getRowSelection(s1, 0, rows);
    MatrixSelection second = heatmap.getRowSelection(s2, 0, rows);
    PrintStream out = new PrintStream(configuration);
    for (int index = 0; index < rows; index++)
        out.println(index + "\t"
                + (first.getIndices().contains(index) ? 1 : (second.getIndices().contains(index) ? 0 : -1)));
    out.flush();
}

From source file:edu.dfci.cccb.mev.analysis.Limma.java

private static void configureColumns(OutputStream configuration, Heatmap heatmap, String s1, String s2)
        throws IOException {
    int columns = heatmap.getSummary().columns();
    MatrixSelection first = heatmap.getColumnSelection(s1, 0, columns);
    MatrixSelection second = heatmap.getColumnSelection(s2, 0, columns);
    PrintStream out = new PrintStream(configuration);
    for (int index = 0; index < columns; index++)
        out.println(index + "\t"
                + (first.getIndices().contains(index) ? 1 : (second.getIndices().contains(index) ? 0 : -1)));
    out.flush();
}

From source file:org.owasp.goatdroid.gui.emulator.Emulator.java

static public void sendLocation(String latitude, String longitude) throws SocketException, IOException {

    TelnetClient telnet = new TelnetClient();
    telnet.setDefaultPort(5554);/*from  w  ww . j  a va2 s  .  com*/
    telnet.connect("localhost");
    PrintStream outStream = new PrintStream(telnet.getOutputStream());
    // geo fix takes longitude/latitude, in that order
    outStream.println("geo fix " + longitude + " " + latitude);
    outStream.flush();
}

From source file:Main.java

private static List<Integer> getAllRelatedPids(final int pid) {
    List<Integer> result = new ArrayList<Integer>(Arrays.asList(pid));
    // use 'ps' to get this pid and all pids that are related to it (e.g.
    // spawned by it)
    try {//  www.j  a va2s  .  c  o  m

        final Process suProcess = Runtime.getRuntime().exec("su");

        new Thread(new Runnable() {

            @Override
            public void run() {
                PrintStream outputStream = null;
                try {
                    outputStream = new PrintStream(new BufferedOutputStream(suProcess.getOutputStream(), 8192));
                    outputStream.println("ps");
                    outputStream.println("exit");
                    outputStream.flush();
                } finally {
                    if (outputStream != null) {
                        outputStream.close();
                    }
                }

            }
        }).run();

        if (suProcess != null) {
            try {
                suProcess.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        BufferedReader bufferedReader = null;
        try {
            bufferedReader = new BufferedReader(new InputStreamReader(suProcess.getInputStream()), 8192);
            while (bufferedReader.ready()) {
                String[] line = SPACES_PATTERN.split(bufferedReader.readLine());
                if (line.length >= 3) {
                    try {
                        if (pid == Integer.parseInt(line[2])) {
                            result.add(Integer.parseInt(line[1]));
                        }
                    } catch (NumberFormatException ignore) {
                    }
                }
            }
        } finally {
            if (bufferedReader != null) {
                bufferedReader.close();
            }
        }
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    return result;
}

From source file:de.tynne.benchmarksuite.Main.java

private static void listSuites(Map<BenchmarkSuite, BenchmarkProducer> suites, PrintStream ps) {
    suites.entrySet().stream().sorted(//from   ww  w  .  j  a va  2 s  .c  o  m
            (a, b) -> nameFor(a.getKey(), a.getValue()).compareToIgnoreCase(nameFor(b.getKey(), b.getValue())))
            .forEach((e) -> {
                ps.printf("%s: %s\n", nameFor(e.getKey(), e.getValue()), e.getKey().enabled());
            });
    ps.flush();
}