import java.io.BufferedOutputStream;import java.io.BufferedInputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;public class TalentFile{public final static int READ = 1,WRITE = 2; File file = null;OutputStream output = null;InputStream input = null;public boolean Create(String path,int rw){file = new File(path);        try {                if((rw&WRITE)==WRITE)            output = new BufferedOutputStream(new FileOutputStream(file));            if((rw&READ)==READ)            input = new BufferedInputStream(new FileInputStream(file));        } catch(FileNotFoundException e) {                com.Loge("TalentFile.Create:"+e.getMessage());               return false;        } catch(SecurityException e){            com.Loge("TalentFile.Create:"+e.getMessage());              return false;        }return true;}public void Close(){try {if(output!=null)output.close();if(input!=null)input.close();} catch (IOException e) {com.Loge("TalentFile.Close:"+e.getMessage());}}public long Length(){if(file==null) return 0;long len = 0;try{len = file.length();}catch(SecurityException e){com.Loge("TalentFile.Length:"+e.getMessage());}return len;}public void Flush(){try {if(output!=null)output.flush();} catch (IOException e) {com.Loge("TalentFile.Flush:"+e.getMessage());}}/**读取最多*/public int Read(byte[] buf,int offset,int length){int readLen = 0;try {readLen = input.read(buf,offset,length);} catch (IOException e) {com.Loge("TalentFile.Read:"+e.getMessage());} catch(IndexOutOfBoundsException e){com.Loge("TalentFile.Read:"+e.getMessage());}return readLen;}/***/public int Read(byte[] buf,int offset){int readLen = 0;try {readLen = input.read(buf,offset,buf.length);} catch (IOException e) {com.Loge("TalentFile.Read:"+e.getMessage());} catch(IndexOutOfBoundsException e){com.Loge("TalentFile.Read:"+e.getMessage());}return readLen;}public boolean Write(byte[] buf,int offset){        try {output.write(buf,offset,buf.length);} catch (IOException e) {com.Loge("TalentFile.Write:"+e.getMessage());return false;} catch (IndexOutOfBoundsException e){com.Loge("TalentFile.Write:"+e.getMessage());return false;}        return true;}public boolean Write(byte[] buf,int offset,int count){        try {output.write(buf,offset,count);} catch (IOException e) {com.Loge("TalentFile.Write:"+e.getMessage());return false;} catch (IndexOutOfBoundsException e){com.Loge("TalentFile.Write:"+e.getMessage());return false;}        return true;}}

更多相关文章

  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 C/C++ source files 全局宏定义
  2. [Android]CircleList 圆弧形 ListView
  3. Android(安卓)requestFeature() must be
  4. android 调用系统相机程序,存放文件夹创建
  5. android 用Pull 创建XML
  6. Android(安卓)之 Gallery画廊用法
  7. Android(安卓)System.gc()与Runtime.getR
  8. android 下Excel操作
  9. android 判断网络是否可用,并调用系统设置
  10. Android(安卓)Wifi框架流程分析