简单问题:如何把String 变成InputStream或者它的子类?

freebeekf 2001-12-02 05:03:04
查StringBufferInputStream,它告诉我不推荐使用。。。
...全文
91 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Happy_shrimp 2001-12-03
  • 打赏
  • 举报
回复
FileOutputStream xmlStringOut = null;
try{
xmlStringOut = new FileOutputStream("name");
}catch(FileNotFoundException e){
System.out.println("You have to create a file");
}
String s = "EQWRQWRWQ";
try{
xmlStringOut.write(s.getBytes());
}catch(IOException e){}
ChDw 2001-12-03
  • 打赏
  • 举报
回复
ByteArrayInputStream bais = new ByteArrayInputStream(str.getBytes());
hahaha88 2001-12-03
  • 打赏
  • 举报
回复
这样行不行?

- 把String变成一个char[]
- 把这个char[]wrap成一个java.io.InputStream

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧