001    /*
002     * Apache License
003     * Version 2.0, January 2004
004     * http://www.apache.org/licenses/
005     *
006     * Copyright 2008 by chenillekit.org
007     *
008     * Licensed under the Apache License, Version 2.0 (the "License");
009     * you may not use this file except in compliance with the License.
010     * You may obtain a copy of the License at
011     *
012     * http://www.apache.org/licenses/LICENSE-2.0
013     */
014    
015    package org.chenillekit.core.streams;
016    
017    import java.io.StringReader;
018    
019    /**
020     * Wraps a String as an InputStream.
021     * <p/>
022     * stolen from org.apache.tools.ant.filters.StringInputStream
023     *
024     * @version $Id: StringInputStream.java 594 2009-12-05 15:17:26Z mlusetti $
025     */
026    public class StringInputStream extends ReaderInputStream
027    {
028        /**
029         * Composes a stream from a String
030         *
031         * @param source The string to read from. Must not be <code>null</code>.
032         */
033        public StringInputStream(String source)
034        {
035            super(new StringReader(source));
036        }
037    
038        /**
039         * Composes a stream from a String with the specified encoding
040         *
041         * @param source   The string to read from. Must not be <code>null</code>.
042         * @param encoding The encoding scheme.  Also must not be <CODE>null</CODE>.
043         */
044        public StringInputStream(String source, String encoding)
045        {
046            super(new StringReader(source), encoding);
047        }
048    }