import java.io.IOException;
import java.util.ArrayList;
/**  * File operators. Like: delete, create, move...  * Use linux shell to implement these operators.  * So, only for linux like operator system.   * All return the execute process, and if the requested program can not be executed,  * may throws IOException.  * And all files or diretorys String parameters are absolute path.  * The return new {@code Process} object that represents the native process.  * */ public class LinuxFileCommand { public final Runtime shell; //private static final int c = 0; /** * Constructor. /data/busybox/ * @param * interface with the environment in which they are running * */ public LinuxFileCommand(Runtime runtime) { // TODO Auto-generated constructor stub shell = runtime; } /** Delete {@code file} file, nerver prompt*/ public final Process deleteFile(String file) throws IOException{ String[] cmds = {"rm", file}; return shell.exec(cmds); } public final Process delete(String file) throws IOException { String[] cmds = {"rm", "-r", file}; return shell.exec(cmds); } public final Process deleteMult(String[] cmds) throws IOException{ return shell.exec(cmds); } /** Delete {@code dire} directory, nerver prompt*/ public final Process deleteDirectory(String dire) throws IOException{ String[] cmds = {"rm", "-r", dire}; return shell.exec(cmds); } /** Create {@code file} file, if file has already exist, update the * file access and modification time to current time. * @throws IOException  * */ public final Process createFile(String file) throws IOException { String[] cmds = {"touch", file}; return shell.exec(cmds); } /** Create directory. If parent path is not existed, also create parent directory * @throws IOException */ public final Process createDirectory(String dire) throws IOException{ String[] cmds = {"mkdir", dire}; return shell.exec(cmds); } /** Move or rename(if they in the same directory) file or directory * @throws IOException */ public final Process moveFile(String src, String dir) throws IOException{ String[] cmds = {"mv", src, dir}; return shell.exec(cmds); } /** Copy file * @throws IOException */ public final Process copyFile(String src, String dir) throws IOException{ String[] cmds = {"cp", "-r", src, dir}; return shell.exec(cmds); } /**` * File soft Link * @throws IOException  * */ public final Process linkFile(String src, String dir) throws IOException{ String[] cmds = {"ln", "-l", src, dir}; return shell.exec(cmds); } public final Process du_s(String file) throws IOException{ String[] cmds = {"du", "-s", file}; return shell.exec(cmds); }
public final Process ls_lhd(String file) throws IOException{ String[] cmds = {"ls", "-l", file}; return shell.exec(cmds); } public final Process ls_Directory(String directory) throws IOException{ if (directory.equals("/")) directory = ""; String[] cmds = {"ls", "-a", directory}; return shell.exec(cmds); } }

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android获取网络数据
  2. Android WiFi On/Off sequence diagram
  3. Android(安卓)DataBinding 快速入门
  4. Android版本更新【转】
  5. Is there any way to define a min and m
  6. android abd
  7. Android内置窗口
  8. Android(安卓)KEYCODE键值对应大全
  9. Android保存Log信息到本地文件
  10. 【Android】配置APK开发环境