Example usage for java.lang Terminator Terminator

List of usage examples for java.lang Terminator Terminator

Introduction

In this page you can find the example usage for java.lang Terminator Terminator.

Prototype

Terminator

Source Link

Usage

From source file:org.dvlyyon.net.netconf.transport.ssh.SshConnection.java

/**
 * Processes the input data stream for messages using the (older) EndOfMessage format - as specified by the now-
 * obsoleted RFC 4742./*  w w  w .  ja  v  a 2s .co  m*/
 *
 * @param logStr        StringBuilder used to accumulate trace data.
 * @return              String containing response message.
 * @throws Exception    if an error occurred.
 */
String getDataInEndOfMessageFormat(StringBuilder logStr) throws Exception {
    Terminator terminator = new Terminator();
    // Wait for the response
    byte[] byteBuff = new byte[1024];
    int count = 0;
    StringBuilder respStr = new StringBuilder("");
    while (true) {
        // append
        int c = m_inputStream.read();
        logStr.append((char) c);
        if (c != -1) {
            //byte b = (byte) c;
            byte[] b = terminator.filter(c);
            if (terminator.isAtEnd()) {
                String appendStr = new String(byteBuff, 0, count);
                respStr.append(appendStr);
                break;
            }
            if (b != null) {
                for (int i = 0; i < b.length; i++) {
                    byteBuff[count] = b[i];
                    count++;
                    if (count == 1024) {
                        String appendStr = new String(byteBuff, 0, count);
                        respStr.append(appendStr);
                        count = 0;
                    }
                }
            }
        } else {
            break;
        }
    }
    return respStr.toString();
}

From source file:org.robovm.junit.client.TestClient.java

public void terminate() throws InterruptedException {
    Terminator t = new Terminator();
    runQueue.add(t);
    t.await();
}