class StreamSource {
    /**
     * Get a stream that reads data from the input source. Every call should
     * return a new instance so that multiple readers can read from the source
     * without interfering with each other.
     *
     * @return an {@code InputStream}
     * @throws IOException if an error occurs when opening the stream
     */
    public abstract InputStream getStream() throws IOException;

    /**
     * Helper method that creates a {@code StreamSource} instance that
     * reads data from a file.
     *
     * @param file the data file
     * @return a stream source that reads from {@code file}
     */
    public static StreamSource fromFile(final File file) {
        return new StreamSource() {
            @Override
            public InputStream getStream() throws IOException {
                return new BufferedInputStream(new FileInputStream(file));
            }
        };
    }

    /**
     * Helper method that creates a {@code StreamSource} instance that
     * reads data from a String.
     * @param str the source string
     * @return a stream source that reads from {@code str}
     */
    public static StreamSource fromString(final String str) {<FILL_FUNCTION_BODY>}
}

        return new StreamSource() {
            private final byte[] sbuf = str.getBytes(StandardCharsets.UTF_8);

            @Override
            public InputStream getStream() throws IOException {
                return new ByteArrayInputStream(sbuf);
            }
        };
    
<no_super_class>