推荐安卓开发神器(里面有各种UI特效和android代码库实例)
import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.text.TextUtils; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.nio.channels.FileChannel; import java.nio.channels.WritableByteChannel; public class FileUtil { public static File copyFile(String paramString1, String paramString2) { File localFile; try { Object localObject1 = new File(paramString1); if (!((File)localObject1).exists()) { localFile = null; } else { localFile = new File(paramString2); if (!localFile.exists()) localFile.createNewFile(); localObject1 = new FileInputStream((File)localObject1); Object localObject2 = new FileOutputStream(localFile); localObject1 = ((FileInputStream)localObject1).getChannel(); localObject2 = ((FileOutputStream)localObject2).getChannel(); while (true) { if (((FileChannel)localObject1).position() == ((FileChannel)localObject1).size()) { ((FileChannel)localObject1).close(); ((FileChannel)localObject2).close(); localFile = localFile; break label170; } if (((FileChannel)localObject1).size() - ((FileChannel)localObject1).position() >= 20971520L) break; int i = (int)(((FileChannel)localObject1).size() - ((FileChannel)localObject1).position()); ((FileChannel)localObject1).transferTo(((FileChannel)localObject1).position(), i, (WritableByteChannel)localObject2); ((FileChannel)localObject1).position(((FileChannel)localObject1).position() + i); } } } catch (Exception localException) { while (true) { localFile = null; break; int j = 20971520; } } label170: return (File)(File)localFile; } public static boolean copyFile(String paramString, FileOutputStream paramFileOutputStream) { int j; try { File localFile = new File(paramString); int i; if (!localFile.exists()) { i = 0; } else { FileChannel localFileChannel2 = new FileInputStream(i).getChannel(); FileChannel localFileChannel1 = paramFileOutputStream.getChannel(); while (true) { if (localFileChannel2.position() == localFileChannel2.size()) { localFileChannel2.close(); localFileChannel1.close(); j = 1; break label133; } if (localFileChannel2.size() - localFileChannel2.position() >= 20971520L) break; int k = (int)(localFileChannel2.size() - localFileChannel2.position()); localFileChannel2.transferTo(localFileChannel2.position(), k, j); localFileChannel2.position(localFileChannel2.position() + k); } } } catch (Exception localException) { while (true) { j = 0; break; int m = 20971520; } } label133: return j; } public static boolean deleteDirectory(File paramFile) { if ((paramFile != null) && (paramFile.isDirectory())) { File[] arrayOfFile = paramFile.listFiles(); int j = arrayOfFile.length; int i = 0; while (true) if (i >= j) { if (paramFile.delete()) i = 1; else i = 0; } else { if (!arrayOfFile[i].isDirectory()) { if (!arrayOfFile[i].delete()) { i = 0; break; } } else if (!deleteDirectory(arrayOfFile[i])) break label81; i++; continue; label81: i = 0; } return i; } throw new IllegalArgumentException("Argument " + paramFile + " is not a directory. "); } public static boolean deleteDirectory(String paramString) { return deleteDirectory(new File(paramString)); } public static boolean emptyDirectory(File paramFile) { File[] arrayOfFile = paramFile.listFiles(); int i = 1; for (int j = 0; ; j++) { if (j >= arrayOfFile.length) return i; if (arrayOfFile[j].delete()) continue; i = 0; } } public static boolean emptyDirectory(String paramString) { return emptyDirectory(new File(paramString)); } public static byte[] getFileData(String paramString) { Object localObject; if (TextUtils.isEmpty(paramString)) localObject = null; while (true) { return localObject; localObject = new File(paramString); if (!((File)localObject).exists()) { localObject = null; continue; } try { FileInputStream localFileInputStream = new FileInputStream((File)localObject); localObject = new byte[localFileInputStream.available()]; Exception localException2; try { localFileInputStream.read(localObject, 0, localObject.length); localFileInputStream.close(); } catch (Exception localException2) { localObject = localObject; localException2 = localException1; } localException2.printStackTrace(); localObject = localObject; } catch (Exception localException3) { while (true) localObject = null; } } } public static String getFileName(String paramString) { return new File(paramString).getName(); } public static String getFilePath(String paramString) { return new File(paramString).getAbsolutePath(); } public static long getFileSize(String paramString) { return new File(paramString).length(); } public static String getFileType(File paramFile) { return getTypePart(paramFile.getName()); } public static String getNamePart(String paramString) { int i = getPathLsatIndex(paramString); int k = paramString.length(); String str; if (i != -1) { if (i != k - 1) { str = paramString.substring(i + 1); } else { int j = getPathLsatIndex(paramString, str - 1); if (j != -1) str = paramString.substring(j + 1, str); else if (k != 1) str = paramString.substring(0, str); else str = paramString; } } else str = paramString; return str; } public static String getNamePartWithoutType(String paramString) { String str1 = getNamePart(paramString); String str2 = getTypePart(paramString); return str1.substring(0, str1.length() - (1 + str2.length())); } public static int getPathIndex(String paramString) { int i = paramString.indexOf('/'); if (i == -1) i = paramString.indexOf('\\'); return i; } public static int getPathIndex(String paramString, int paramInt) { int i = paramString.indexOf('/', paramInt); if (i == -1) i = paramString.indexOf('\\', paramInt); return i; } public static int getPathLsatIndex(String paramString) { int i = paramString.lastIndexOf('/'); if (i == -1) i = paramString.lastIndexOf('\\'); return i; } public static int getPathLsatIndex(String paramString, int paramInt) { int i = paramString.lastIndexOf('/', paramInt); if (i == -1) i = paramString.lastIndexOf('\\', paramInt); return i; } public static String getPathPart(String paramString) { int k = getPathLsatIndex(paramString); int i = paramString.length(); String str2; if (k != -1) { if (k != i - 1) { String str1 = paramString.substring(0, k); } else { int j = getPathLsatIndex(paramString, k - 1); if (j != -1) str2 = paramString.substring(0, j); else str2 = ""; } } else str2 = ""; return str2; } public static String getSubpath(String paramString1, String paramString2) { int i = paramString2.indexOf(paramString1); String str; if (i == -1) str = paramString2; else str = paramString2.substring(1 + (str + paramString1.length())); return str; } public static String getTypePart(String paramString) { int j = paramString.lastIndexOf('.'); int i = paramString.length(); String str; if ((j != -1) && (j != i - 1)) str = paramString.substring(j + 1, i); else str = ""; return str; } public static String getUNIXfilePath(String paramString) { return toUNIXpath(new File(paramString).getAbsolutePath()); } public static boolean isFileExist(String paramString) { return new File(paramString).isFile(); } public static boolean makeDirectory(File paramFile) { File localFile = paramFile.getParentFile(); boolean bool; if (localFile == null) bool = false; else bool = bool.mkdirs(); return bool; } public static boolean makeDirectory(String paramString) { return makeDirectory(new File(paramString)); } public static boolean renameFile(String paramString1, String paramString2) { return new File(paramString1).renameTo(new File(paramString2)); } public static String toUNIXpath(String paramString) { return paramString.replace('\\', '/'); } public static void touch(File paramFile) { long l = System.currentTimeMillis(); if (!paramFile.exists()) { System.err.println("file not found:" + paramFile.getName()); System.err.println("Create a new file:" + paramFile.getName()); } try { boolean bool = paramFile.createNewFile(); if ((!bool) || (!paramFile.setLastModified(l))); return; } catch (IOException localIOException) { while (true) localIOException.printStackTrace(); } } public static void touch(String paramString) { touch(new File(paramString)); } public static void touch(File[] paramArrayOfFile) { for (int i = 0; ; i++) { if (i >= paramArrayOfFile.length) return; touch(paramArrayOfFile); } } public static void touch(String[] paramArrayOfString) { File[] arrayOfFile = new File[paramArrayOfString.length]; for (int i = 0; ; i++) { if (i >= paramArrayOfString.length) { touch(arrayOfFile); return; } arrayOfFile[i] = new File(paramArrayOfString[i]); } } public static String trimType(String paramString) { int i = paramString.lastIndexOf("."); String str; if (i == -1) str = paramString; else str = paramString.substring(0, str); return str; } public void saveBitmap(Bitmap paramBitmap, String paramString) throws IOException { Object localObject = new File(paramString); try { localObject = new FileOutputStream((File)localObject); if (paramBitmap.compress(Bitmap.CompressFormat.JPEG, 100, (OutputStream)localObject)) { ((FileOutputStream)localObject).flush(); ((FileOutputStream)localObject).close(); } return; } catch (FileNotFoundException localFileNotFoundException) { while (true) localFileNotFoundException.printStackTrace(); } catch (IOException localIOException) { while (true) localIOException.printStackTrace(); } } }
相关推荐
编写带缓存的文件操作类 从执行体程序库中的CLLogger类可知,通过缓存要写入文件中的数据,能够提高读写磁盘的性能 请编写一个文件操作的封装类,其要求如下: 需要提供open/read/write/lseek/close等函数的封装函数...
java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java文件操作类java...
PHP 写的一个简单文件操作类,支持 PHP4 PHP5
c#文件操作类,读取,写入;根据传入的虚拟路径或物理路径获取文件、目录;
php文件操作类,包括创建文件夹、递归复制、递归删除、递归移动
php中的面向对象,文件操作类,可以查看文件,删除文件,上传文件。包含构造函数,打开工作文件目录,向当前文件夹添加文件,同时检查是否有重名的文件,将临时文件复制到当前目录中。
请编写一个文件操作的封装类,其要求如下: 需要提供open/read/write/lseek/close等函数的封装函数 该类要提供数据缓存服务。 调用该类的写操作接口时,数据要首先写到缓存,然后再根据策略写到文件中。 调用该类的...
FTP操作类、导出Excel、配置文件操作类、 文件操作类、弹出消息类、XML操作类、 弹出消息类、分词辅助类、时间操作类、 汉字转拼音、压缩解压缩、条形码、 正则表达式、日历、上传下载、 视频转换类、随机数类、条形...
易语言文件操作类模块源码,文件操作类模块,取对象,取驱动器集合,追加路径,取驱动器名称,取父文件夹名称,取文件名,取不带扩展名的文件名,取扩展名,取完整路径名,取临时文件名,驱动器是否存在,文件是否存在,文件夹是否...
C#文件操作类
这个“C#类库典藏版源码”包含了多种实用的类,如FTP操作类、导出Excel、文件操作类和弹出消息类,这些都是日常开发中常见的需求。接下来,我们将深入探讨这些知识点。 1. FTP操作类:FTP(File Transfer Protocol...
php真正的ZIP文件操作类,php将文件夹打包成zip文件,分析了php操作zip文件的技巧,有兴趣的朋友可以引用参考,或者朋友们有更好的zip类,可以上传到我们PHP中文网与我们一起学习分享。
易语言源码易语言文件操作类模块源码.rar 易语言源码易语言文件操作类模块源码.rar 易语言源码易语言文件操作类模块源码.rar 易语言源码易语言文件操作类模块源码.rar 易语言源码易语言文件操作类模块源码.rar ...
C#文件和目录操作类 主要包含文件操作类和目录操作类两个类方法
文件操作,Excel文件操作类头文件CSpreadSheet_src,Excel文件操作类头文件CSpreadSheet_src,Excel文件操作类头文件CSpreadSheet_src,Excel文件操作类头文件CSpreadSheet_src
非常简单的ini配置文件操作类,光看.h或者.cpp就能明白用法。若有使用上的疑惑,可以参见链接:http://blog.csdn.net/xyz59886/article/details/79423311
jar包 博文链接:https://wakin2003.iteye.com/blog/242473
网友封装的C#文件操作类,包括目录创建、文件内容读写等;