String转InputStream

String转InputStream

方法一:ReaderInputStream

方法一:ReaderInputStream
ReaderInputStream inputStream = new ReaderInputStream(
	CharSource.wrap(new String(routeSb)).openStream());

方法二:Apache Common之IOUtils

//方法二:Apache Common之IOUtils
InputStream targetStream = IOUtils.toInputStream(
	new String(routeSb), StandardCharsets.UTF_8.name());

方法三:字节数组

//方法三:字节数组
InputStream inputStreamRoute = new ByteArrayInputStream(
	new String(routeSb).getBytes());

你可能感兴趣的:(Java,java,开发语言)