String str = ReadFile.read(getClass().getResourceAsStream("sence/"+file));
public static String read(InputStream inputStream) {
BufferedReader reader = null;
String laststr = "";
try{
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
reader = new BufferedReader(inputStreamReader);
String tempString = null;
while((tempString = reader.readLine()) != null){
laststr += tempString;
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(reader != null){
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return laststr;
}
网友评论