源码如下:
private void readFile(String filePath){
if(filePath == null) return;
File file = new File(filePath);
if(file.isDirectory()){
Log.d(TAG, filePath + " is directory");
return;
}else{
try {
InputStream is = new FileInputStream(file);
if(is != null){
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while((line = br.readLine()) != null){
Log.d(TAG, line);
}
}
} catch (FileNotFoundException e) {
Log.d(TAG, filePath + " doesn't found!");
}catch (IOException e) {
Log.d(TAG, filePath + " read exception, " + e.getMessage());
}
}
}