private static String getContentFromFile(String parent,String child) { //用bean不用map原因,
String content="";
FileInputStream fis=null;
File file = new File(parent,child);
try {
fis = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
content = reader.readLine();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return content;
}
你这个代码只读取了文件里面第一行的内容。