实际开发遇到(InputStream 编码格式转换方法)
public
static List
<String
> getStrFromInsByCode(InputStream is
, String code
){
StringBuilder builder
=new
StringBuilder();
BufferedReader reader
=null
;
List
<String
> list
= new ArrayList
<>();
try
{
reader
= new
BufferedReader(new
InputStreamReader(is
,code
));
String line
= null
;
while((line
=reader
.readLine())!=null
){
builder
.append(line
+"\n");
list
.add(line
);
}
} catch
(Exception e
) {
e
.printStackTrace();
}finally
{
try
{
reader
.close();
} catch
(IOException e
) {
e
.printStackTrace();
}
}
return list
;
}
代码如下(示例):
InputStream is
= entity
.getContent();
List
<String
> campaignReportList
= getStrFromInsByCode(is
, "GBK");
转载请注明原文地址: https://lol.8miu.com/read-9259.html