```java
```java
public static String reader(String filePath) {
try {
File file = new File(filePath);
if (file.isFile() && file.exists()) {
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "UTF-8");
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = bufferedReader.readLine();
while (lineTxt != null) {
return lineTxt;
}
}
} catch (UnsupportedEncodingException | FileNotFoundException e) {
Log.e("FileUtils","Cannot find the file specified!");
e.printStackTrace();
} catch (IOException e) {
Log.e("FileUtils","Error reading file content!");
e.printStackTrace();
}
return null;
}
/**
* 保存文件
*
* @param filename 路径
* @param content 内容
*/
public static void writeToExternalStoragePublic(String filename, String content) {
String path = ROOTPATH + "/users/";
Log.e("123456sss", "file" + path);
try {
boolean exists = (new File(path)).exists();
if (!exists) {
new File(path).mkdirs();
}
FileOutputStream fOut = new FileOutputStream(path + filename, true);
fOut.write(content.getBytes());
fOut.flush();
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static boolean deleteDirs(String path) {
Log.e("128999", "path = " + path);
File file = new File(path);
if (!file.exists()) {
return true;
}
if (file.isDirectory()) {
File[] childs = file.listFiles();
if (null == childs) {
return false;
}
boolean result = true;
for (File child : childs) {
result = result && deleteDirs(child.getAbsolutePath());
}
Log.e("128999", "file1-------------------" + file.toString());
try {
boolean ret = file.delete();
return result && ret;
} catch (Exception e) {
e.printStackTrace();
return false;
}
} else {
Log.e("128999", "file2-------------------" + file.toString());
try {
boolean ret = file.delete();
return ret;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
/**
* 检查是否有文件存在
*
* @return
*/
public static boolean existPhoneFile() {
String path = ROOTPATH + "/users/PHONE";
boolean exists = (new File(path)).exists();
return exists;
}