Android 处理txt文件类FileUtils 利用java反射机制访问非sdk类和函数
2010-09-10 00:59:00 来源:WEB开发网Android系统内部提供了一个不错的txt文本读写类,但目前并没有公开提供给标准的SDK,FileUtils类的源代码如下,可以很好的操作Linux下的文本文件。
public class FileUtils
{
public static final int S_IRWXU = 00700;
public static final int S_IRUSR = 00400;
public static final int S_IWUSR = 00200;
public static final int S_IXUSR = 00100;
public static final int S_IRWXG = 00070;
public static final int S_IRGRP = 00040;
public static final int S_IWGRP = 00020;
public static final int S_IXGRP = 00010;
public static final int S_IRWXO = 00007;
public static final int S_IROTH = 00004;
public static final int S_IWOTH = 00002;
public static final int S_IXOTH = 00001;
public static final class FileStatus {
public int dev;
public int ino;
public int mode;
public int nlink;
public int uid;
public int gid;
public int rdev;
public long size;
public int blksize;
public long blocks;
public long atime;
public long mtime;
public long ctime;
}
public static native boolean getFileStatus (String path, FileStatus status);
private static final Pattern SAFE_FILENAME_PATTERN = Pattern.compile("[\w%+,./=_-]+");
public static boolean copyFile(File srcFile, File destFile) {
boolean result = false;
try {
InputStream in = new FileInputStream(srcFile);
try {
result = copyToFile(in, destFile);
} finally {
in.close();
}
} catch (IOException e) {
result = false;
}
return result;
}
public static boolean copyToFile (InputStream inputStream, File destFile) {
- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
- ››android bitmap与base64字符串的互相转换
赞助商链接