首页天道酬勤string类型怎么输出,inputstream实例

string类型怎么输出,inputstream实例

张世龙 05-05 13:21 59次浏览

publicstaticstringinputstream2string (inputstream is ) throws mhdz {

string buffer buffer=new string buffer (;

String line=' ';

while((line=in.readline ) )!=空) {

buffer.append(line;

}

return buffer.toString (;

//return new string (buffer.tostring ).getbytes('iso-8859-1 ' )、' utf-8 ' );

}

publicstaticstringinput2byte (inputstream instream ) throws mhdz {

bytearrayoutputstreamswapstream=newbytearrayoutputstream (;

byte[] buff=new byte[100];

int rc=0;

while((RC=Instream.read ) buff,0,100 ) ) 0

sapstream.write(buff,0,rc );

}

byte [ ] in2b=swapstream.to bytearray (;

返回新字符串(in2b、' UTF-8 ';

}

//带代码

publicstaticstringis2string (inputstream in ) throws mhdz { )

string buffer out=new string buffer (;

inputstreamreaderinread=newinputstreamreader (in,' UTF-8 ';

char[] b=new char[4096];

for(intn; (n=inread.read(b ) b )!=-1; () )。

out.append (新字符串) b,0,n );

}

return out.toString (;

}

string的反转字符串方法,clob转string