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. android中设置进度条读取
  2. android 保存和读取文件
  3. Android读取本地TXT文件
  4. android 保存和读取文件
  5. Android(安卓)Http网络数据传输备忘
  6. Android常用权限
  7. android 读写文件
  8. Android(安卓)uses-permission 总结
  9. android 读取sd卡中的图片

随机推荐

  1. Android实现App自动重启
  2. 《第一行代码Android(第3版)》— Android(
  3. 使用FragmentTabHost时,tabwidget被framen
  4. Android(安卓)Asynchronous Http Client
  5. Android(安卓)移动安全知识技术全解(加固
  6. set androids action bar title color
  7. Android(安卓)异常:Immutable bitmap pass
  8. android 获取局域网内其他手机的ip
  9. Android下修改SeekBar样式
  10. Android(安卓)获取无线蓝牙MAC信息代码