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


Java FileNotFoundException.toString方法代碼示例

本文整理匯總了Java中java.io.FileNotFoundException.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java FileNotFoundException.toString方法的具體用法?Java FileNotFoundException.toString怎麽用?Java FileNotFoundException.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.FileNotFoundException的用法示例。


在下文中一共展示了FileNotFoundException.toString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupDestinationFile

import java.io.FileNotFoundException; //導入方法依賴的package包/類
/**
 * Prepare the destination file to receive data. If the file already exists,
 * we'll set up appropriately for resumption.
 */
private void setupDestinationFile(State state, InnerState innerState)
        throws StopRequest {
    if (state.mFilename != null) { // only true if we've already run a
                                   // thread for this download
        if (!Helpers.isFilenameValid(state.mFilename)) {
            // this should never happen
            throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,
                    "found invalid internal destination filename");
        }
        // We're resuming a download that got interrupted
        File f = new File(state.mFilename);
        if (f.exists()) {
            long fileLength = f.length();
            if (fileLength == 0) {
                // The download hadn't actually started, we can restart from
                // scratch
                f.delete();
                state.mFilename = null;
            } else if (mInfo.mETag == null) {
                // This should've been caught upon failure
                f.delete();
                throw new StopRequest(DownloaderService.STATUS_CANNOT_RESUME,
                        "Trying to resume a download that can't be resumed");
            } else {
                // All right, we'll be able to resume this download
                try {
                    state.mStream = new FileOutputStream(state.mFilename, true);
                } catch (FileNotFoundException exc) {
                    throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,
                            "while opening destination for resuming: " + exc.toString(), exc);
                }
                innerState.mBytesSoFar = (int) fileLength;
                if (mInfo.mTotalBytes != -1) {
                    innerState.mHeaderContentLength = Long.toString(mInfo.mTotalBytes);
                }
                innerState.mHeaderETag = mInfo.mETag;
                innerState.mContinuingDownload = true;
            }
        }
    }

    if (state.mStream != null) {
        closeDestination(state);
    }
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:50,代碼來源:DownloadThread.java


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