首页天道酬勤java string转char,java字符串转map

java string转char,java字符串转map

张世龙 05-05 13:15 68次浏览

常用的几种InputStream 和String 互相转换的方法。

1.

inputstream inputstream=resource.get inputstream (; byte[] bytes=new byte[0]; bytes=new byte [ inputstream.available (); Inputstream.read(bytes; System.out.println ('输出' bytes ); 2.(()我个人建议这样做) ) )。

inputstream inputstream=resource.get inputstream (; stringbuilder sb=new stringbuilder (; 字符串线; bufferedreaderbr=newbufferedreader (newInputstreamreader ) inputstream ); while((line=br.readline ) )!=空(sb.append ) line ); }String str=sb.toString (; System.out.println ('输出' str ); 3.Apache (方便)

stringstr=I outils.tostring (inputstream,' utf-8 ';

将String转换为InputStream

1.

inputstream is=newbytearrayinputstream (str.getbytes (); 2.Apache

inputstreamtargetstream=I outils.to inputstream (str,StandardCharsets.UTF_8.name );

double转字符串,string转char字符