//摘自新浪认证
private static void makesureParentExist(File file_) {
if (file_ == null) {
return;
}
File parent = file_.getParentFile();
if ((parent != null) && (!(parent.exists())))
mkdirs(parent);
}
private static void mkdirs(File dir_) {
if (dir_ == null) {
return;
}
if ((!(dir_.exists())) && (!(dir_.mkdirs())))
throw new RuntimeException("fail to make " + dir_.getAbsolutePath());
}
private static void delete(File f) {
if ((f != null) && (f.exists()) && (!(f.delete()))) {
throw new RuntimeException(f.getAbsolutePath() + " doesn't be deleted!");
}
}
private static boolean __createNewFile(File file_) {
if (file_ == null) {
return false;
}
makesureParentExist(file_);
if (file_.exists())
delete(file_);
try {
return file_.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}