Package org.jnode.util

Examples of org.jnode.util.ReaderInputStream


            try {
                final ShellManager sm = InitialNaming.lookup(ShellManager.NAME);
                final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager();
                final PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
                TextConsole console = createConsoleWithShell(conMgr, out);
                System.setIn(new ReaderInputStream(console.getIn()));
                System.setOut(new PrintStream(new WriterOutputStream(console.getOut(), false), true));
                System.setErr(new PrintStream(new WriterOutputStream(console.getErr(), false), true));
            } catch (Exception ex) {
                // FIXME
                System.out.println("Problem creating the isolated console");
View Full Code Here


    }

    private Socket createSocketForInput(Closeable closeable) throws IOException {
        InputStream in;
        if (closeable instanceof Reader) {
            in = new ReaderInputStream((Reader) closeable);       
        } else {
            in = (InputStream) closeable;
        }
        return new IsolateSocket(in);
    }
View Full Code Here

        return printWriter;
    }
   
    public synchronized InputStream getInputStream() {
        if (inputStream == null) {
            inputStream = new ReaderInputStream(reader, getEncoding());
        }
        return inputStream;
    }
View Full Code Here

public class ReaderInputStreamTest {

    @Test
    public void testEmpty() throws Exception {
        Reader r = new StringReader("");
        ReaderInputStream ris = new ReaderInputStream(r, "UTF-8");
        BufferedReader bisr = new BufferedReader(new InputStreamReader(ris));
        String line = bisr.readLine();
        Assert.assertNull(line);
    }
View Full Code Here

    @Test
    public void testOneLine() throws Exception {
        final String LINE = "The quick brown fox jumped over the lazy dog";
        Reader r = new StringReader(LINE + "\n");
        ReaderInputStream ris = new ReaderInputStream(r, "UTF-8");
        BufferedReader bisr = new BufferedReader(new InputStreamReader(ris));
        String line = bisr.readLine();
        Assert.assertEquals(LINE, line);
    }
View Full Code Here

    @Test
    public void testByteAtATime() throws Exception {
        final String LINE = "The quick brown fox jumped over the lazy dog\n";
        final byte[] BYTES = LINE.getBytes();
        Reader r = new StringReader(LINE);
        ReaderInputStream ris = new ReaderInputStream(r, "UTF-8");
        for (int i = 0; i < BYTES.length; i++) {
            Assert.assertEquals(BYTES[i], ris.read());
        }
        Assert.assertEquals(-1, ris.read());
    }
View Full Code Here

    @Test
    public void testBigBuffer() throws Exception {
        final String LINE = "The quick brown fox jumped over the lazy dog\n";
        Reader r = new StringReader(LINE);
        ReaderInputStream ris = new ReaderInputStream(r, "UTF-8");
        byte[] buffer = new byte[100];
        Assert.assertEquals(LINE.length(), ris.read(buffer));
    }
View Full Code Here

    public void testTwoBytesAtATime() throws Exception {
        final String LINE = "The quick brown fox jumped over the lazy dog";
        final byte[] BYTES = LINE.getBytes();
        final byte[] buffer = new byte[2];
        Reader r = new StringReader(LINE);
        ReaderInputStream ris = new ReaderInputStream(r, "UTF-8");
        for (int i = 0; i < BYTES.length; i += 2) {
            Assert.assertEquals(2, ris.read(buffer));
            Assert.assertEquals(BYTES[i], buffer[0]);
            Assert.assertEquals(BYTES[i + 1], buffer[1]);
        }
        Assert.assertEquals(-1, ris.read(buffer));
    }
View Full Code Here

    }

    @Test
    public void testEmpty2() throws Exception {
        Reader r = new StringReader("");
        ReaderInputStream ris = new ReaderInputStream(r, "UTF-8");
        Assert.assertEquals(-1, ris.read());
    }
View Full Code Here

        this.inputStream = deproxy(inputStream);
    }

    public synchronized InputStream getInputStream() {
        if (inputStream == null) {
            inputStream = new ReaderInputStream(reader, getEncoding());
        }
        return inputStream;
    }
View Full Code Here

TOP

Related Classes of org.jnode.util.ReaderInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.