當前位置: 首頁>>代碼示例>>Java>>正文


Java UniFile.createFile方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:seven332,項目名稱:EhViewer,代碼行數:19,代碼來源:SpiderDen.java

示例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);
    }
}
 
開發者ID:seven332,項目名稱:EhViewer,代碼行數:20,代碼來源:CommonOperations.java

示例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);
    }
}
 
開發者ID:seven332,項目名稱:Nimingban,代碼行數:40,代碼來源:HeaderImageView.java

示例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");
        }
    }
}
 
開發者ID:seven332,項目名稱:EhViewer,代碼行數:9,代碼來源:DownloadsScene.java

示例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();
    }
}
 
開發者ID:seven332,項目名稱:EhViewer,代碼行數:49,代碼來源:SpiderDen.java


注:本文中的com.hippo.unifile.UniFile.createFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。