Topic: 请问如何将string转化为inputstream

  Print this page

1.请问如何将string转化为inputstream Copy to clipboard
Posted by: hafocus
Posted on: 2006-10-18 21:02

原来用

new StringBufferInputStream(string);

可是api说已经过时了,此类未能正确地将字符转换为字节。从 JDK 1.1 开始,从字符串创建流的首选方法是通过 StringReader 类进行创建。

可是如何通过StringReader 类进行创建呢?

(通过ByteArrayInputStream也可以,但是我想看看StringReader 的方法)

2.Re:请问如何将string转化为inputstream [Re: hafocus] Copy to clipboard
Posted by: ranchgirl
Posted on: 2006-10-19 00:02

Can you read javadoc?

http://java.sun.com/j2se/1.5.0/docs/api/java/io/StringReader.html

3.Re:请问如何将string转化为inputstream [Re: hafocus] Copy to clipboard
Posted by: hafocus
Posted on: 2006-10-19 09:13

看过,不过用StringReader(String s)
Create a new string reader.
后我就不知道如何转化成inputstream 了!

4.Re:请问如何将string转化为inputstream [Re: hafocus] Copy to clipboard
Posted by: hafocus
Posted on: 2006-10-19 10:41

看来还真的是个问题

http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4094886

5.Re:请问如何将string转化为inputstream [Re: hafocus] Copy to clipboard
Posted by: joezhou
Posted on: 2006-10-24 01:16

ByteArrayInputStream
http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/io/ByteArrayInputStream.html

String.getBytes().

6.Re:请问如何将string转化为inputstream [Re: hafocus] Copy to clipboard
Posted by: kimjava
Posted on: 2006-11-03 02:33

InputStream input=new FileInputStream(String s);

7.Re:请问如何将string转化为inputstream [Re: kimjava] Copy to clipboard
Posted by: cxp108
Posted on: 2006-11-03 08:47

kimjava wrote:
InputStream input=new FileInputStream(String s);

???
这不是完全违背了提问者的本意么?

8.Re:请问如何将string转化为inputstream [Re: hafocus] Copy to clipboard
Posted by: kingecg
Posted on: 2006-11-09 13:03

要干什么啊。不行的话就自己写个算了


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923