Friday, April 2, 2010

Convert String to a InputStream

Following code snippet show how to $subject.

import java.io.UnsupportedEncodingException;
import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class StringSample {
public static void main(String[] args) {
String textInput = "Convert String to InputStream";
try {
InputStream is = new ByteArrayInputStream(textInput.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}

No comments: