AndBase开发框架  1.6
 全部  命名空间 文件 函数 变量 枚举值 
| 静态 Public 成员函数 | 静态 Private 属性 | 所有成员列表
com.ab.util.AbFileUtil类 参考

class  FileLastModifSort
 

静态 Public 成员函数

static Bitmap getBitmapFromSD (String url, int type, int desiredWidth, int desiredHeight)
 
static Bitmap getBitmapFromSD (File file, int type, int desiredWidth, int desiredHeight)
 
static Bitmap getBitmapFromSD (File file)
 
static Bitmap getBitmapFromByte (byte[] imgByte, String fileName, int type, int desiredWidth, int desiredHeight)
 
static Bitmap getBitmapFromURL (String url, int type, int desiredWidth, int desiredHeight)
 
static Bitmap getBitmapFromSrc (String src)
 
static Bitmap getBitmapFromAsset (Context context, String fileName)
 
static Drawable getDrawableFromAsset (Context context, String fileName)
 
static String downloadFile (String url, String dirPath)
 
static int getContentLengthFromUrl (String Url)
 
static String getRealFileNameFromUrl (String url)
 
static String getRealFileName (HttpURLConnection connection)
 
static String getRealFileName (HttpResponse response)
 
static String getCacheFileNameFromUrl (String url)
 
static String getCacheFileNameFromUrl (String url, HttpResponse response)
 
static String getCacheFileNameFromUrl (String url, HttpURLConnection connection)
 
static String getMIMEFromUrl (String url, HttpURLConnection connection)
 
static String getMIMEFromUrl (String url, HttpResponse response)
 
static byte[] getByteArrayFromSD (String path)
 
static void writeByteArrayToSD (String path, byte[] content, boolean create)
 
static boolean isCanUseSD ()
 
static void initFileDir (Context context)
 
static int freeSpaceOnSD ()
 
static boolean clearDownloadFile ()
 
static String readAssetsByName (Context context, String name, String encoding)
 
static String readRawByName (Context context, int id, String encoding)
 
static String getDownloadRootDir (Context context)
 
static String getImageDownloadDir (Context context)
 
static String getFileDownloadDir (Context context)
 
static String getCacheDownloadDir (Context context)
 
static String getDbDownloadDir (Context context)
 
static int getFreeSdSpaceNeededToCache ()
 

静态 Private 属性

static String downloadRootDir = null
 
static String imageDownloadDir = null
 
static String fileDownloadDir = null
 
static String cacheDownloadDir = null
 
static String dbDownloadDir = null
 
static int freeSdSpaceNeededToCache = 200*1024*1024
 

详细描述

© 2012 amsoft.cn 名称:AbFileUtil.java 描述:文件操作类.

作者
还如一梦中
版本
v1.0
日期
:2013-01-18 下午11:52:13

成员函数说明

static boolean com.ab.util.AbFileUtil.clearDownloadFile ( )
inlinestatic

删除所有缓存文件.

返回
true, if successful
static String com.ab.util.AbFileUtil.downloadFile ( String  url,
String  dirPath 
)
inlinestatic

下载网络文件到SD卡中.如果SD中存在同名文件将不再下载

参数
url要下载文件的网络地址
dirPaththe dir path
返回
下载好的本地文件地址
static int com.ab.util.AbFileUtil.freeSpaceOnSD ( )
inlinestatic

计算sdcard上的剩余空间.

返回
the int
static Bitmap com.ab.util.AbFileUtil.getBitmapFromAsset ( Context  context,
String  fileName 
)
inlinestatic

描述:获取Asset中的图片资源.

参数
contextthe context
fileNamethe file name
返回
Bitmap 图片
static Bitmap com.ab.util.AbFileUtil.getBitmapFromByte ( byte[]  imgByte,
String  fileName,
int  type,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:将图片的byte[]写入本地文件.

参数
imgByte图片的byte[]形势
fileName文件名称,需要包含后缀,如.jpg
type图片的处理类型(剪切或者缩放到指定大小,参考AbConstant类)
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static Bitmap com.ab.util.AbFileUtil.getBitmapFromSD ( String  url,
int  type,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:通过文件的网络地址从SD卡中读取图片,如果SD中没有则自动下载并保存.

参数
url文件的网络地址
type图片的处理类型(剪切或者缩放到指定大小,参考AbImageUtil类) 如果设置为原图,则后边参数无效,得到原图
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static Bitmap com.ab.util.AbFileUtil.getBitmapFromSD ( File  file,
int  type,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:通过文件的本地地址从SD卡读取图片.

参数
filethe file
type图片的处理类型(剪切或者缩放到指定大小,参考AbConstant类) 如果设置为原图,则后边参数无效,得到原图
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static Bitmap com.ab.util.AbFileUtil.getBitmapFromSD ( File  file)
inlinestatic

描述:通过文件的本地地址从SD卡读取图片.

参数
filethe file
返回
Bitmap 图片
static Bitmap com.ab.util.AbFileUtil.getBitmapFromSrc ( String  src)
inlinestatic

描述:获取src中的图片资源.

参数
src图片的src路径,如(“image/arrow.png”)
返回
Bitmap 图片
static Bitmap com.ab.util.AbFileUtil.getBitmapFromURL ( String  url,
int  type,
int  desiredWidth,
int  desiredHeight 
)
inlinestatic

描述:根据URL从互连网获取图片.

参数
url要下载文件的网络地址
type图片的处理类型(剪切或者缩放到指定大小,参考AbConstant类)
desiredWidth新图片的宽
desiredHeight新图片的高
返回
Bitmap 新图片
static byte [] com.ab.util.AbFileUtil.getByteArrayFromSD ( String  path)
inlinestatic

描述:从sd卡中的文件读取到byte[].

参数
pathsd卡中文件路径
返回
byte[]
static String com.ab.util.AbFileUtil.getCacheDownloadDir ( Context  context)
inlinestatic

Gets the cache download dir.

参数
contextthe context
返回
the cache download dir
static String com.ab.util.AbFileUtil.getCacheFileNameFromUrl ( String  url)
inlinestatic

获取文件名(不含后缀).

参数
url文件地址
返回
文件名
static String com.ab.util.AbFileUtil.getCacheFileNameFromUrl ( String  url,
HttpResponse  response 
)
inlinestatic

获取文件名(.后缀),外链模式和通过网络获取.

参数
url文件地址
responsethe response
返回
文件名
static String com.ab.util.AbFileUtil.getCacheFileNameFromUrl ( String  url,
HttpURLConnection  connection 
)
inlinestatic

获取文件名(.后缀),外链模式和通过网络获取.

参数
url文件地址
connectionthe connection
返回
文件名
static int com.ab.util.AbFileUtil.getContentLengthFromUrl ( String  Url)
inlinestatic

描述:获取网络文件的大小.

参数
Url图片的网络路径
返回
int 网络文件的大小
static String com.ab.util.AbFileUtil.getDbDownloadDir ( Context  context)
inlinestatic

Gets the db download dir.

参数
contextthe context
返回
the db download dir
static String com.ab.util.AbFileUtil.getDownloadRootDir ( Context  context)
inlinestatic

Gets the download root dir.

参数
contextthe context
返回
the download root dir
static Drawable com.ab.util.AbFileUtil.getDrawableFromAsset ( Context  context,
String  fileName 
)
inlinestatic

描述:获取Asset中的图片资源.

参数
contextthe context
fileNamethe file name
返回
Drawable 图片
static String com.ab.util.AbFileUtil.getFileDownloadDir ( Context  context)
inlinestatic

Gets the file download dir.

参数
contextthe context
返回
the file download dir
static int com.ab.util.AbFileUtil.getFreeSdSpaceNeededToCache ( )
inlinestatic

Gets the free sd space needed to cache.

返回
the free sd space needed to cache
static String com.ab.util.AbFileUtil.getImageDownloadDir ( Context  context)
inlinestatic

Gets the image download dir.

参数
contextthe context
返回
the image download dir
static String com.ab.util.AbFileUtil.getMIMEFromUrl ( String  url,
HttpURLConnection  connection 
)
inlinestatic

获取文件后缀,本地.

参数
url文件地址
connectionthe connection
返回
文件后缀
static String com.ab.util.AbFileUtil.getMIMEFromUrl ( String  url,
HttpResponse  response 
)
inlinestatic

获取文件后缀,本地和网络.

参数
url文件地址
responsethe response
返回
文件后缀
static String com.ab.util.AbFileUtil.getRealFileName ( HttpURLConnection  connection)
inlinestatic

获取真实文件名(xx.后缀),通过网络获取.

参数
connection连接
返回
文件名
static String com.ab.util.AbFileUtil.getRealFileName ( HttpResponse  response)
inlinestatic

获取真实文件名(xx.后缀),通过网络获取.

参数
responsethe response
返回
文件名
static String com.ab.util.AbFileUtil.getRealFileNameFromUrl ( String  url)
inlinestatic

获取文件名,通过网络获取.

参数
url文件地址
返回
文件名
static void com.ab.util.AbFileUtil.initFileDir ( Context  context)
inlinestatic

描述:初始化存储目录.

参数
contextthe context
static boolean com.ab.util.AbFileUtil.isCanUseSD ( )
inlinestatic

描述:SD卡是否能用.

返回
true 可用,false不可用
static String com.ab.util.AbFileUtil.readAssetsByName ( Context  context,
String  name,
String  encoding 
)
inlinestatic

描述:读取Assets目录的文件内容.

参数
contextthe context
namethe name
encodingthe encoding
返回
the string
static String com.ab.util.AbFileUtil.readRawByName ( Context  context,
int  id,
String  encoding 
)
inlinestatic

描述:读取Raw目录的文件内容.

参数
contextthe context
idthe id
encodingthe encoding
返回
the string
static void com.ab.util.AbFileUtil.writeByteArrayToSD ( String  path,
byte[]  content,
boolean  create 
)
inlinestatic

描述:将byte数组写入文件.

参数
paththe path
contentthe content
createthe create

类成员变量说明

String com.ab.util.AbFileUtil.cacheDownloadDir = null
staticprivate

默认缓存目录.

String com.ab.util.AbFileUtil.dbDownloadDir = null
staticprivate

默认下载数据库文件的目录.

String com.ab.util.AbFileUtil.downloadRootDir = null
staticprivate

默认APP根目录.

String com.ab.util.AbFileUtil.fileDownloadDir = null
staticprivate

默认下载文件目录.

int com.ab.util.AbFileUtil.freeSdSpaceNeededToCache = 200*1024*1024
staticprivate

剩余空间大于200M才使用SD缓存.

String com.ab.util.AbFileUtil.imageDownloadDir = null
staticprivate

默认下载图片文件目录.


该类的文档由以下文件生成: