Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Tint Browser for Android
 * 
 * Copyright (C) 2012 - to infinity and beyond J. Devauchelle and contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 3 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

import java.io.InputStream;

import android.content.Context;

import android.webkit.WebResourceResponse;

public class Main {
    /**
     * Load a resource as WebResourceResponse
     * @param context The current context.
     * @param resourceId The resource id.
     * @return The loaded string.
     */
    public static WebResourceResponse getWebResourceResponseFromRawResource(Context context, int resourceId,
            String mime, String encoding) {
        WebResourceResponse result = null;

        InputStream is = context.getResources().openRawResource(resourceId);
        if (is != null) {
            result = new WebResourceResponse(mime, encoding, is);
        } else {
            result = null;
        }

        return result;
    }
}