本文整理汇总了Java中com.blankj.utilcode.util.FileUtils类的典型用法代码示例。如果您正苦于以下问题:Java FileUtils类的具体用法?Java FileUtils怎么用?Java FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileUtils类属于com.blankj.utilcode.util包,在下文中一共展示了FileUtils类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initAssets
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void initAssets() {
if (!FileUtils.isFileExists(Config.TEST_APK_PATH)) {
ThreadPoolUtils poolUtils = new ThreadPoolUtils(ThreadPoolUtils.SingleThread, 1);
poolUtils.execute(new Runnable() {
@Override
public void run() {
try {
FileIOUtils.writeFileFromIS(Config.TEST_APK_PATH, getAssets().open("test_install"), false);
} catch (IOException e) {
e.printStackTrace();
}
}
});
} else {
LogUtils.d("test apk existed.");
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:UtilsApp.java
示例2: takePhoto
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void takePhoto() {
final String currentPhotoName = getPhotoName();
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final File temFile = new File(FileUtil.CAMERA_PHOTO_DIR, currentPhotoName);
//兼容7.0及以上的写法
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
final ContentValues contentValues = new ContentValues(1);
contentValues.put(MediaStore.Images.Media.DATA, temFile.getPath());
final Uri uri = DELEGATE.getContext().getContentResolver()
.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
//需要将uri路径转换成实际路径
final File realFile =
FileUtils.getFileByPath(FileUtil.getRealFilePath(DELEGATE.getContext(), uri));
final Uri realUri = Uri.fromFile(realFile);
CameraImageBean.getInstance().setPath(realUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
} else {
final Uri fileUri = Uri.fromFile(temFile);
CameraImageBean.getInstance().setPath(fileUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
}
DELEGATE.startActivityForResult(intent, RequestCodes.TAKE_PHOTO);
}
开发者ID:remerber,项目名称:FastEc,代码行数:25,代码来源:CameraHandler.java
示例3: copyFileInOtherThread
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void copyFileInOtherThread(String imagePath) {
final String imagePaths = imagePath;
new AsyncTask<String, Integer, Boolean>() {
@Override
protected void onPreExecute() {
mView.showLoading("加载中...");
}
@Override
protected Boolean doInBackground(String... params) {
return FileUtils.copyFile(new File(imagePaths), mImageFile);
}
@Override
protected void onPostExecute(Boolean aBoolean) {
mView.unShowLoading();
if (aBoolean) {
displayImage();
} else {
ToastUtils.showShort("图片读取失败");
}
}
}.execute();
}
开发者ID:ifadai,项目名称:SuperNote,代码行数:26,代码来源:EditNotePresenter.java
示例4: copyFile
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void copyFile( final Activity activity){
new AsyncTask<String,Integer,Boolean>(){
@Override
protected void onPreExecute() {
mView.showLoading("保存中...");
}
@Override
protected Boolean doInBackground(String... params) {
return FileUtils.copyFile(getImageFile(activity),
new File(Constans.imageSaveFolder+mImageName));
}
@Override
protected void onPostExecute(Boolean aBoolean) {
mView.unShowLoading();
if(aBoolean){
ToastUtils.showLong("已保存至/SuperNote/image/中");
} else {
ToastUtils.showLong("保存失败,请查看图片是否已存在");
}
}
}.execute();
}
开发者ID:ifadai,项目名称:SuperNote,代码行数:26,代码来源:ImagePresenter.java
示例5: deleteFile
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void deleteFile(final Activity activity){
new AsyncTask<String,Integer,Boolean>(){
@Override
protected void onPreExecute() {
mView.showLoading("删除中...");
}
@Override
protected Boolean doInBackground(String... params) {
return FileUtils.deleteFile(getImageFile(activity));
}
@Override
protected void onPostExecute(Boolean aBoolean) {
mView.unShowLoading();
if(aBoolean){
mView.setResultAndFinish();
} else {
ToastUtils.showShort("删除失败");
}
}
}.execute();
}
开发者ID:ifadai,项目名称:SuperNote,代码行数:25,代码来源:ImagePresenter.java
示例6: takePhoto
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
/**
* 拍照
*/
private void takePhoto() {
final String currentPhotoName = getPhotoName();
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final File tempFile = new File(FileUtil.CAMERA_PHOTO_DIR, currentPhotoName);
//兼容7.0及以上的写法
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
final ContentValues contentValues = new ContentValues(1);
contentValues.put(MediaStore.Images.Media.DATA, tempFile.getPath());
final Uri uri = ACTIVITY.getApplicationContext().getContentResolver().
insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
//需要讲Uri路径转化为实际路径
final File realFile =
FileUtils.getFileByPath(FileUtil.getRealFilePath(ACTIVITY.getApplicationContext(), uri));
final Uri realUri = Uri.fromFile(realFile);
CameraImageBean.getInstance().setPath(realUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
} else {
final Uri fileUri = Uri.fromFile(tempFile);
CameraImageBean.getInstance().setPath(fileUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
}
ACTIVITY.startActivityForResult(intent, RequestCodes.TAKE_PHOTO);
}
开发者ID:organizationAllink,项目名称:wzyx-android-user,代码行数:28,代码来源:CameraHandler.java
示例7: initAssets
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void initAssets() {
if (!FileUtils.isFileExists(Config.getTestApkPath())) {
try {
FileIOUtils.writeFileFromIS(Config.getTestApkPath(), getAssets().open("test_install.apk"), false);
} catch (IOException e) {
e.printStackTrace();
}
}
}
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:10,代码来源:UtilsApp.java
示例8: initAssets
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void initAssets() {
if (!FileUtils.isFileExists(Config.getTestApkPath())) {
try {
FileIOUtils.writeFileFromIS(Config.getTestApkPath(), getAssets().open("test_install"), false);
} catch (IOException e) {
e.printStackTrace();
}
}
}
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:10,代码来源:UtilsApp.java
示例9: releaseInstallApk
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
public static void releaseInstallApk(final OnReleasedListener listener) {
if (!FileUtils.isFileExists(Config.TEST_APK_PATH)) {
ThreadPoolUtils poolUtils = new ThreadPoolUtils(ThreadPoolUtils.SingleThread, 1);
poolUtils.execute(new Runnable() {
@Override
public void run() {
try {
FileIOUtils.writeFileFromIS(
Config.TEST_APK_PATH,
Utils.getApp().getAssets().open("test_install"),
false
);
} catch (IOException e) {
e.printStackTrace();
}
if (listener != null) {
listener.onReleased();
}
}
});
} else {
if (listener != null) {
listener.onReleased();
}
LogUtils.d("test apk existed.");
}
}
开发者ID:Blankj,项目名称:AndroidUtilCode,代码行数:28,代码来源:AssertHelper.java
示例10: deleteFile
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void deleteFile(String mNoteId) {
File file = Utils.getContext().getExternalFilesDir(mNoteId);
if (file.exists()) {
FileUtils.deleteDir(file);
}
}
开发者ID:ifadai,项目名称:SuperNote,代码行数:7,代码来源:NoteMainPresenter.java
示例11: deleteNoteFile
import com.blankj.utilcode.util.FileUtils; //导入依赖的package包/类
private void deleteNoteFile(String noteId){
File file=Utils.getContext().getExternalFilesDir(noteId);
if(file.exists()){
FileUtils.deleteDir(file);
}
}
开发者ID:ifadai,项目名称:SuperNote,代码行数:7,代码来源:NoteModel.java
注:本文中的com.blankj.utilcode.util.FileUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论