@@ -194,18 +194,18 @@ public static boolean autoDeleteCacheFile(File file, long expiredDuration) {
194194
195195 }
196196
197- public static boolean createFolder (String filepath ) {
198-
199- File file = new File (filepath );
200-
201- if ((isSDCardMounted () || isSDCardMountedReadOnly ()) && file .exists ()) {
197+ /**递归地创建文件夹*/
198+ public static boolean createFolder (File file ) {
199+ if (file .exists ()) {
202200 return true ;
203201 } else {
204- if (isSDCardMounted ()) {
205- return file .mkdirs ();
206- } else
202+ File p = file .getParentFile ();
203+ if (createFolder (p )){
204+ file .mkdir ();
205+ return true ;
206+ }else {
207207 return false ;
208-
208+ }
209209 }
210210 }
211211
@@ -222,60 +222,62 @@ public static void delFile(String strFileName) {
222222
223223 }
224224
225- public static void writeDatatoFile (String rst ) {
226- if (isSDCardMounted ()) {
227-
228- String realfilename = datafilepath + datafilename ;
229-
230- if (createFolder (datafilepath )) {
231-
232- if (isFileExit (realfilename )) {
233- delFile (realfilename );
234- }
235-
236- try {
237-
238- BufferedWriter output = new BufferedWriter (new FileWriter (
239- realfilename ));
240- output .write (rst );
241- output .close ();
242-
243- Log .i ("FileUtils" , "write data to file " );
244- } catch (Exception e ) {
245-
246- }
247-
248- }
249-
250- }
251- }
252-
253- public static void writeVDetailtoFile (String rst , String plid ) {
254- if (isSDCardMounted ()) {
255-
256- String realfilename = datafilepath + plid ;
257-
258- if (createFolder (datafilepath )) {
259-
260- if (isFileExit (realfilename )) {
261- delFile (realfilename );
262- }
263-
264- try {
265-
266- BufferedWriter output = new BufferedWriter (new FileWriter (
267- realfilename ));
268- output .write (rst );
269- output .close ();
270-
271- } catch (Exception e ) {
272-
273- }
274-
275- }
276-
277- }
278- }
225+ // @Deprecated
226+ // public static void writeDatatoFile(String rst) {
227+ // if (isSDCardMounted()) {
228+ //
229+ // String realfilename = datafilepath + datafilename;
230+ //
231+ // if (createFolder(datafilepath)) {
232+ //
233+ // if (isFileExit(realfilename)) {
234+ // delFile(realfilename);
235+ // }
236+ //
237+ // try {
238+ //
239+ // BufferedWriter output = new BufferedWriter(new FileWriter(
240+ // realfilename));
241+ // output.write(rst);
242+ // output.close();
243+ //
244+ // Log.i("FileUtils", "write data to file ");
245+ // } catch (Exception e) {
246+ //
247+ // }
248+ //
249+ // }
250+ //
251+ // }
252+ // }
253+
254+ // @Deprecated
255+ // public static void writeVDetailtoFile(String rst, String plid) {
256+ // if (isSDCardMounted()) {
257+ //
258+ // String realfilename = datafilepath + plid;
259+ //
260+ // if (createFolder(datafilepath)) {
261+ //
262+ // if (isFileExit(realfilename)) {
263+ // delFile(realfilename);
264+ // }
265+ //
266+ // try {
267+ //
268+ // BufferedWriter output = new BufferedWriter(new FileWriter(
269+ // realfilename));
270+ // output.write(rst);
271+ // output.close();
272+ //
273+ // } catch (Exception e) {
274+ //
275+ // }
276+ //
277+ // }
278+ //
279+ // }
280+ // }
279281
280282 public static String readDatatoFile (String filepath , String filename ) {
281283
0 commit comments