Example usage for java.lang Helper.GenerateSaveFileError toString

List of usage examples for java.lang Helper.GenerateSaveFileError toString

Introduction

In this page you can find the example usage for java.lang Helper.GenerateSaveFileError toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.example.download.DownloadThread.java

/**
 * Read HTTP response headers and take appropriate action, including setting up the destination
 * file and updating the database./*from w w  w. j av  a  2 s .  c o  m*/
 */
private void processResponseHeaders(State state, InnerState innerState, HttpResponse response)
        throws StopRequest {
    if (innerState.mContinuingDownload) {
        // ignore response headers on resume requests
        return;
    }

    readResponseHeaders(state, innerState, response);

    try {
        state.mFilename = Helper.generateSaveFile(mContext, mInfo.mUri, mInfo.mHint,
                innerState.mHeaderContentLocation, state.mMimeType, mInfo.mDestination, mInfo.mTotalBytes,
                mInfo.mSource);
    } catch (Helper.GenerateSaveFileError exc) {
        throw new StopRequest(exc.mStatus, exc.mMessage);
    }
    try {
        state.mStream = new FileOutputStream(state.mFilename);
    } catch (FileNotFoundException exc) {
        throw new StopRequest(DownloadManager.Impl.STATUS_FILE_ERROR,
                "while opening destination file: " + exc.toString(), exc);
    }
    Utils.D("writing " + mInfo.mUri + " to " + state.mFilename);
    Utils.D("totalbytes " + mInfo.mTotalBytes);
    updateDatabaseFromHeaders(state, innerState);
    // check connectivity again now that we know the total size
    checkConnectivity(state);
}

From source file:com.lan.nicehair.common.download.DownloadThread.java

/**
 * Read HTTP response headers and take appropriate action, including setting up the destination
 * file and updating the database.//from  w  w w.j ava2 s.  c  o m
 */
private void processResponseHeaders(State state, InnerState innerState, HttpResponse response)
        throws StopRequest {
    if (innerState.mContinuingDownload) {
        // ignore response headers on resume requests
        return;
    }

    readResponseHeaders(state, innerState, response);

    try {
        state.mFilename = Helper.generateSaveFile(mContext, mInfo.mUri, mInfo.mHint,
                innerState.mHeaderContentLocation, state.mMimeType, mInfo.mDestination, mInfo.mTotalBytes,
                mInfo.mSource);
    } catch (Helper.GenerateSaveFileError exc) {
        throw new StopRequest(exc.mStatus, exc.mMessage);
    }
    try {
        state.mStream = new FileOutputStream(state.mFilename);
    } catch (FileNotFoundException exc) {
        throw new StopRequest(DownloadManager.Impl.STATUS_FILE_ERROR,
                "while opening destination file: " + exc.toString(), exc);
    }
    AppLog.d(TAG, "writing " + mInfo.mUri + " to " + state.mFilename);
    AppLog.d(TAG, "totalbytes " + mInfo.mTotalBytes);
    updateDatabaseFromHeaders(state, innerState);
    // check connectivity again now that we know the total size
    checkConnectivity(state);
}