Java Code Examples for com.facebook.internal.FileLruCache#openPutStream()

The following examples show how to use com.facebook.internal.FileLruCache#openPutStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UrlRedirectCache.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 6 votes vote down vote up
static void cacheUrlRedirect(Context context, URL fromUrl, URL toUrl) {
    if (fromUrl == null || toUrl == null) {
        return;
    }

    OutputStream redirectStream = null;
    try {
        FileLruCache cache = getCache(context);
        redirectStream = cache.openPutStream(fromUrl.toString(), REDIRECT_CONTENT_TAG);
        redirectStream.write(toUrl.toString().getBytes());
    } catch (IOException e) {
        // Caching is best effort
    } finally {
        Utility.closeQuietly(redirectStream);
    }
}
 
Example 2
Source File: UrlRedirectCache.java    From HypFacebook with BSD 2-Clause "Simplified" License 6 votes vote down vote up
static void cacheUrlRedirect(Context context, URL fromUrl, URL toUrl) {
    if (fromUrl == null || toUrl == null) {
        return;
    }

    OutputStream redirectStream = null;
    try {
        FileLruCache cache = getCache(context);
        redirectStream = cache.openPutStream(fromUrl.toString(), REDIRECT_CONTENT_TAG);
        redirectStream.write(toUrl.toString().getBytes());
    } catch (IOException e) {
        // Caching is best effort
    } finally {
        Utility.closeQuietly(redirectStream);
    }
}
 
Example 3
Source File: UrlRedirectCache.java    From FacebookNewsfeedSample-Android with Apache License 2.0 6 votes vote down vote up
static void cacheUrlRedirect(Context context, URL fromUrl, URL toUrl) {
    if (fromUrl == null || toUrl == null) {
        return;
    }

    OutputStream redirectStream = null;
    try {
        FileLruCache cache = getCache(context);
        redirectStream = cache.openPutStream(fromUrl.toString(), REDIRECT_CONTENT_TAG);
        redirectStream.write(toUrl.toString().getBytes());
    } catch (IOException e) {
        // Caching is best effort
    } finally {
        Utility.closeQuietly(redirectStream);
    }
}