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);
}
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;
}
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();
}
Aggregations