当前位置: 首页>>代码示例>>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;未经允许,请勿转载。