Here you can find the source of getInputStream(String data)
Parameter | Description |
---|---|
data | the stream data |
public static InputStream getInputStream(String data)
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.io.EOFException; public class Main { /**/*from w w w.j a v a2 s . c om*/ * returns an input stream that will give you * back the specified string * * @param data the stream data * @return the input stream * */ public static InputStream getInputStream(String data) { final String theData = data; return new InputStream() { final String data = theData; int position = 0; public int read() throws EOFException { if (position < data.length()) return data.charAt(position++); return -1; } @Override public int available() { return data.length() - position; // include terminating -1 } }; } }