Java StringReader Create getReaderFromString(String s)

Here you can find the source of getReaderFromString(String s)

Description

Create a reader to read from a string.

License

Open Source License

Parameter

Parameter Description
s the string or null

Return

the reader

Declaration

public static Reader getReaderFromString(String s) 

Method Source Code

//package com.java2s;
/*//from ww  w  .  ja  va2s.co m
 * Copyright 2004-2013 H2 Group. Multiple-Licensed under the H2 License,
 * Version 1.0, and under the Eclipse Public License, Version 1.0
 * (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group
 */

import java.io.Reader;
import java.io.StringReader;

public class Main {
    /**
     * Create a reader to read from a string.
     * If the string is null, this method returns null.
     *
     * @param s the string or null
     * @return the reader
     */
    public static Reader getReaderFromString(String s) {
        return s == null ? null : new StringReader(s);
    }
}