android的文件、目录操作(四)

本文介绍如何在Android中进行私有文件和目录的删除、更改、复制、移动等操作,包括具体方法和示例代码。
 

android的文件、目录操作(四)  

2011-03-18 18:08:20|  分类: 工作学习 |  标签: |字号 订阅


  1.     /** 
  2.      * 删除私有文件 
  3.      *  
  4.      * @param fileName 
  5.      * @return 
  6.      */  
  7.     public boolean delDataFile(String fileName) {  
  8.         File file = new File(FILESPATH + fileName);  
  9.         return delFile(file);  
  10.     }  
  11.   
  12.     /** 
  13.      * 删除私有目录 
  14.      *  
  15.      * @param dirName 
  16.      * @return 
  17.      */  
  18.     public boolean delDataDir(String dirName) {  
  19.         File file = new File(FILESPATH + dirName);  
  20.         return delDir(file);  
  21.     }  
  22.   
  23.     /** 
  24.      * 更改私有文件名 
  25.      *  
  26.      * @param oldName 
  27.      * @param newName 
  28.      * @return 
  29.      */  
  30.     public boolean renameDataFile(String oldName, String newName) {  
  31.         File oldFile = new File(FILESPATH + oldName);  
  32.         File newFile = new File(FILESPATH + newName);  
  33.         return oldFile.renameTo(newFile);  
  34.     }  
  35.   
  36.     /** 
  37.      * 在私有目录下进行文件复制 
  38.      *  
  39.      * @param srcFileName 
  40.      *            : 包含路径及文件名 
  41.      * @param destFileName 
  42.      * @return 
  43.      * @throws IOException 
  44.      */  
  45.     public boolean copyDataFileTo(String srcFileName, String destFileName)  
  46.             throws IOException {  
  47.         File srcFile = new File(FILESPATH + srcFileName);  
  48.         File destFile = new File(FILESPATH + destFileName);  
  49.         return copyFileTo(srcFile, destFile);  
  50.     }  
  51.   
  52.     /** 
  53.      * 复制私有目录里指定目录的所有文件 
  54.      *  
  55.      * @param srcDirName 
  56.      * @param destDirName 
  57.      * @return 
  58.      * @throws IOException 
  59.      */  
  60.     public boolean copyDataFilesTo(String srcDirName, String destDirName)  
  61.             throws IOException {  
  62.         File srcDir = new File(FILESPATH + srcDirName);  
  63.         File destDir = new File(FILESPATH + destDirName);  
  64.         return copyFilesTo(srcDir, destDir);  
  65.     }  
  66.   
  67.     /** 
  68.      * 移动私有目录下的单个文件 
  69.      *  
  70.      * @param srcFileName 
  71.      * @param destFileName 
  72.      * @return 
  73.      * @throws IOException 
  74.      */  
  75.     public boolean moveDataFileTo(String srcFileName, String destFileName)  
  76.             throws IOException {  
  77.         File srcFile = new File(FILESPATH + srcFileName);  
  78.         File destFile = new File(FILESPATH + destFileName);  
  79.         return moveFileTo(srcFile, destFile);  
  80.     }  
  81.   
  82.     /** 
  83.      * 移动私有目录下的指定目录下的所有文件 
  84.      *  
  85.      * @param srcDirName 
  86.      * @param destDirName 
  87.      * @return 
  88.      * @throws IOException 
  89.      */  
  90.     public boolean moveDataFilesTo(String srcDirName, String destDirName)  
  91.             throws IOException {  
  92.         File srcDir = new File(FILESPATH + srcDirName);  
  93.         File destDir = new File(FILESPATH + destDirName);  
  94.         return moveFilesTo(srcDir, destDir);  
  95.     } 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值