Search in sources :

Example 21 with PipedWriter

use of java.io.PipedWriter in project robovm by robovm.

the class OldPipedWriterTest method test_writeI.

public void test_writeI() throws Exception {
    // Test for method void java.io.PipedWriter.write(int)
    pw = new PipedWriter();
    try {
        pw.write(42);
        fail("Test 1: IOException expected.");
    } catch (IOException e) {
    // Expected.
    }
    readerThread = new Thread(reader = new PReader(pw), "writeI");
    readerThread.start();
    pw.write(1);
    pw.write(2);
    pw.write(3);
    pw.close();
    reader.read(3);
    assertTrue("Test 2: The charaacters read do not match the characters written: " + (int) reader.buf[0] + " " + (int) reader.buf[1] + " " + (int) reader.buf[2], reader.buf[0] == 1 && reader.buf[1] == 2 && reader.buf[2] == 3);
}
Also used : PipedWriter(java.io.PipedWriter) IOException(java.io.IOException)

Example 22 with PipedWriter

use of java.io.PipedWriter in project JMRI by JMRI.

the class ScriptOutput method getOutputArea.

/**
     * Provide access to the JTextArea containing all ScriptEngine output.
     * <P>
     * The output JTextArea is not created until this is invoked, so that code
     * that doesn't use this feature can run on GUI-less machines.
     *
     * @return component containing script output
     */
public JTextArea getOutputArea() {
    if (output == null) {
        try {
            // create the output area
            output = new JTextArea();
            // Add the I/O pipes
            PipedWriter pw = new PipedWriter();
            ScriptContext context = JmriScriptEngineManager.getDefault().getDefaultContext();
            context.setErrorWriter(pw);
            context.setWriter(pw);
            // ensure the output pipe is read and stored into a
            // Swing TextArea data model
            PipedReader pr = new PipedReader(pw);
            PipeListener pl = new PipeListener(pr, output);
            pl.start();
        } catch (IOException e) {
            log.error("Exception creating script output area", e);
            return null;
        }
    }
    return output;
}
Also used : PipedWriter(java.io.PipedWriter) JTextArea(javax.swing.JTextArea) ScriptContext(javax.script.ScriptContext) PipeListener(jmri.util.PipeListener) IOException(java.io.IOException) PipedReader(java.io.PipedReader)

Example 23 with PipedWriter

use of java.io.PipedWriter in project adempiere by adempiere.

the class OFX1ToXML method init.

//	OFX1ToXML
/**
	 * Method init
	 * @param br BufferedReader
	 * @throws IOException
	 */
public void init(BufferedReader br) throws IOException {
    m_writer = new BufferedWriter(new PipedWriter(m_reader));
    String line = br.readLine();
    write("<?xml version=\"1.0\"?>\n");
    write("<?OFX ");
    while (line.indexOf('<') != 0) {
        if (line.length() > 0) {
            write(line.replaceAll(":", "=\"") + "\" ");
        }
        line = br.readLine();
    }
    write("?>\n");
    while (line != null) {
        m_ofx += line + "\n";
        line = br.readLine();
    }
    br.close();
    new Thread(this).start();
}
Also used : PipedWriter(java.io.PipedWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

PipedWriter (java.io.PipedWriter)23 PipedReader (java.io.PipedReader)16 IOException (java.io.IOException)14 Templates (javax.xml.transform.Templates)2 Transformer (javax.xml.transform.Transformer)2 StreamResult (javax.xml.transform.stream.StreamResult)2 BufferedWriter (java.io.BufferedWriter)1 Writer (java.io.Writer)1 ScriptContext (javax.script.ScriptContext)1 JTextArea (javax.swing.JTextArea)1 PipeListener (jmri.util.PipeListener)1 BOSHClientRequestListener (org.igniterealtime.jbosh.BOSHClientRequestListener)1 BOSHClientResponseListener (org.igniterealtime.jbosh.BOSHClientResponseListener)1 BOSHException (org.igniterealtime.jbosh.BOSHException)1 BOSHMessageEvent (org.igniterealtime.jbosh.BOSHMessageEvent)1 SmackException (org.jivesoftware.smack.SmackException)1 ConnectionException (org.jivesoftware.smack.SmackException.ConnectionException)1 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)1 XMPPException (org.jivesoftware.smack.XMPPException)1 StreamErrorException (org.jivesoftware.smack.XMPPException.StreamErrorException)1