How to create an InputStream that acts like System.in
<p>I'm trying to create a InputStream class that behaves like a System.in InputStream but can be programatically added to (an endless InputStream that can be dynamically added to)</p>

<p>If you have trouble understanding what I mean, here's what I have wrote and tried</p>

<pre><code>   public class QueuedInputStream extends InputStream {

        private LinkedList&lt;Character&gt; list;

        public QueuedInputStream() {
            list = new LinkedList&lt;Character&gt;();
        }

        @Override
        public int read() throws IOException {
            while (list.isEmpty()) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            int value = (byte)list.get(0).charValue();
            list.remove();
            return value;
        }

        public void queue(String s) {
            char[] chars = s.toCharArray();
            for(int i = 0; i &lt; chars.length; i++) {
                list.add(chars[i]);
            }
        }

    }
</code></pre>

<p>Am I on the right track? Or am I completely wrong in trying to do this?
If you want me to explain more, feel free to ask</p>
