通过获取输入流来读取text文件的内容,再返回一个该内容:
public String getStringFromInputStream(InputStream inputStream){
int hasRead=0;
StringBuilder result=new StringBuilder("");
try{
while((hasRead=inputStream.read(buffer))!=-1){
result.append(new String(buffer,0,hasRead,"GBK"));
}
}catch(Exception e){
e.printStackTrace();
}
return result.toString();
}