本文整理汇总了Java中com.hippo.unifile.UniFile.createFile方法的典型用法代码示例。如果您正苦于以下问题:Java UniFile.createFile方法的具体用法?Java UniFile.createFile怎么用?Java UniFile.createFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hippo.unifile.UniFile
的用法示例。
在下文中一共展示了UniFile.createFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openDownloadOutputStreamPipe
import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
/**
* @param extension without dot
*/
@Nullable
private OutputStreamPipe openDownloadOutputStreamPipe(int index, @Nullable String extension) {
UniFile dir = getDownloadDir();
if (dir == null) {
return null;
}
extension = fixExtension('.' + extension);
UniFile file = dir.createFile(generateImageFilename(index, extension));
if (file != null) {
return new UniFileOutputStreamPipe(file);
} else {
return null;
}
}
示例2: ensureNoMediaFile
import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
public static void ensureNoMediaFile(UniFile file) {
if (null == file) {
return;
}
UniFile noMedia = file.createFile(".nomedia");
if (null == noMedia) {
return;
}
InputStream is = null;
try {
is = noMedia.openInputStream();
} catch (IOException e) {
// Ignore
} finally {
IOUtils.closeQuietly(is);
}
}
示例3: save
import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
@Override
public boolean save(InputStream is, long length, String mediaType, ProgressNotify notify) {
OutputStream os = null;
try {
boolean autoSave = Settings.getSaveImageAuto() && mName != null;
if (autoSave) {
String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mediaType);
if (TextUtils.isEmpty(extension)) {
extension = "jpg";
}
String filename = mName + '.' + extension;
UniFile dir = Settings.getImageSaveLocation();
if (dir != null) {
mTempFile = dir.createFile(filename);
} else {
mTempFile = UniFile.fromFile(NMBAppConfig.createTempFileWithFilename(filename));
}
} else {
mTempFile = UniFile.fromFile(NMBAppConfig.createTempFile());
}
if (mTempFile == null) {
return false;
}
os = mTempFile.openOutputStream();
IOUtils.copy(is, os);
// Notify media scanner
if (autoSave) {
mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mTempFile.getUri()));
}
return true;
} catch (IOException e) {
return false;
} finally {
IOUtils.closeQuietly(os);
}
}
示例4: ensureFile
import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
private void ensureFile() {
if (mFile == null) {
UniFile dir = SpiderDen.getGalleryDownloadDir(mInfo);
if (dir != null && dir.isDirectory()) {
mFile = dir.createFile(".thumb");
}
}
}
示例5: copyFromCacheToDownloadDir
import com.hippo.unifile.UniFile; //导入方法依赖的package包/类
private boolean copyFromCacheToDownloadDir(int index) {
if (sCache == null) {
return false;
}
UniFile dir = getDownloadDir();
if (dir == null) {
return false;
}
// Find image file in cache
String key = EhCacheKeyFactory.getImageKey(mGid, index);
InputStreamPipe pipe = sCache.getInputStreamPipe(key);
if (pipe == null) {
return false;
}
OutputStream os = null;
try {
// Get extension
String extension;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
pipe.obtain();
BitmapFactory.decodeStream(pipe.open(), null, options);
pipe.close();
extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(options.outMimeType);
if (extension != null) {
extension = '.' + extension;
} else {
return false;
}
// Fix extension
extension = fixExtension(extension);
// Copy from cache to download dir
UniFile file = dir.createFile(generateImageFilename(index, extension));
if (file == null) {
return false;
}
os = file.openOutputStream();
IOUtils.copy(pipe.open(), os);
return true;
} catch (IOException e) {
return false;
} finally {
IOUtils.closeQuietly(os);
pipe.close();
pipe.release();
}
}