Java InputStream Create toInputStream(String input, String encoding)

Here you can find the source of toInputStream(String input, String encoding)

Description

to Input Stream

License

Open Source License

Declaration

public static InputStream toInputStream(String input, String encoding)
            throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Angelo Zerr and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from  w w  w . j  av  a  2 s .  c o  m*/
 *     Angelo Zerr <angelo.zerr@gmail.com> - Initial API and implementation 
 *******************************************************************************/

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static InputStream toInputStream(String input, String encoding)
            throws IOException {
        byte bytes[] = encoding == null ? input.getBytes() : input
                .getBytes(encoding);
        return new ByteArrayInputStream(bytes);
    }
}

Related

  1. toInputStream(final String content)
  2. toInputStream(final String input, final String encoding)
  3. toInputStream(OutputStream out)
  4. toInputStream(String input)
  5. toInputStream(String input)
  6. toInputStream(String result, String encoding)
  7. toInputStream(String s, String charSet)
  8. toInputStream(String source)
  9. toInputStream(String text)