Convert String to InputStream - Java File Path IO

Java examples for File Path IO:File Stream

Description

Convert String to InputStream

Demo Code


import java.io.ByteArrayInputStream;
import java.io.InputStream;
 
public class Main {
        public static void main(String args[]){
                String str1 = "this is a test";

                byte[] bytes = str1.getBytes();
               //from www .ja  va 2  s .  c  om
                InputStream inputStream = new ByteArrayInputStream(bytes);
        }
}

Related Tutorials