集册 Java实例教程 将字符串转换为InputStream

将字符串转换为InputStream

欢马劈雪     最近更新时间:2020-01-02 10:19:05

232
将字符串转换为InputStream


import java.io.ByteArrayInputStream;
/*
来 自*
 时代Java - N o w  J a v a . c o m
*/

import java.io.InputStream;

 

public class Main {

        public static void main(String args[]){

                String str1 = "this is a test";


                byte[] bytes = str1.getBytes();

               

                InputStream inputStream = new ByteArrayInputStream(bytes);

        }

}