String Reader InputStream   Leave a comment

 String –> InputStream
InputStream String2InputStream(String str){
   ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes());
   return stream;

InputStream –> String
String inputStream2String(InputStream is){
   BufferedReader in = new BufferedReader(new InputStreamReader(is));
   StringBuffer buffer = new StringBuffer();
   String line = "";
   while ((line = in.readLine()) != null){
   return buffer.toString();

String –> Reader
Reader reader = new StringReader(string);
Reader –> String
BufferedReader br = new BufferedReader(reader);
  String temp = null;
  StringBuffer sb = new StringBuffer();
  String string = sb.toString();

Posted 2009年12月8日 by gw8310 in 未分类


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: