Android Open Source - piRSS Utils






From Project

Back to project page piRSS.

License

The source code is released under:

GNU General Public License

If you think the Android project piRSS listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright (C) 2011 Matthias Jordan <matthias.jordan@googlemail.com>
 *//from ww w . j a v  a  2 s .  c o  m
 * This file is part of piRSS.
 *
 * piRSS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * piRSS 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with piRSS.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.codefu.android.rss.updateservice;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.text.Html;



/**
 * Contains some utility methods.
 * 
 * @author mj
 */
public class Utils {

    /**
     * Makes a string out of an {@link InputStream}.
     * 
     * @param inStream
     *            the input stream
     * @param encoding
     *            the encoding of the input stream
     * @return the string that contains the data from the input stream
     * @throws IOException
     */
    public static String readStream(InputStream inStream, String encoding) throws IOException {
        final StringBuilder builder = new StringBuilder();
        int size = 1024;
        char[] buffer = new char[size];
        int len;
        final InputStreamReader isr = new InputStreamReader(inStream, encoding);
        while ((len = isr.read(buffer, 0, size)) > 0) {
            builder.append(buffer, 0, len);
        }

        return builder.toString();
    }


    /**
     * Removes everything from the given string that looks like an HTML tag.
     * 
     * @param c
     *            the string to clean
     * @return the cleaned string
     */
    public static String htmlClean(String c) {
        if (c == null) {
            return null;
        }
        final String tmp = c.replaceAll("<[\\s\\S]*?>", "").trim();
        final String out = Html.fromHtml(tmp).toString();
        return out;
    }

}




Java Source Code List

de.codefu.android.rss.AboutActivity.java
de.codefu.android.rss.BootCompletedHandler.java
de.codefu.android.rss.CursorChangedReceiver.java
de.codefu.android.rss.MainPreferences.java
de.codefu.android.rss.UserNotification.java
de.codefu.android.rss.db.DB.java
de.codefu.android.rss.db.FeedProvider.java
de.codefu.android.rss.db.ItemHelper.java
de.codefu.android.rss.db.ItemProvider.java
de.codefu.android.rss.db.UriHelper.java
de.codefu.android.rss.feedlist.FeedListAdapter.java
de.codefu.android.rss.feedlist.FeedList.java
de.codefu.android.rss.feedprops.AddFeed.java
de.codefu.android.rss.feedprops.FeedProps.java
de.codefu.android.rss.item.ItemAct.java
de.codefu.android.rss.itemlist.ItemListAdapter.java
de.codefu.android.rss.itemlist.ItemList.java
de.codefu.android.rss.updateservice.AutoPollService.java
de.codefu.android.rss.updateservice.DateFormat3339.java
de.codefu.android.rss.updateservice.FeedHandlerClient.java
de.codefu.android.rss.updateservice.FeedHandler.java
de.codefu.android.rss.updateservice.InsertService.java
de.codefu.android.rss.updateservice.ServiceComm.java
de.codefu.android.rss.updateservice.UpdateService.java
de.codefu.android.rss.updateservice.UrlHttpRetriever.java
de.codefu.android.rss.updateservice.Utils.java
de.codefu.android.rss.updateservice.WakeLockHolder.java
de.codefu.android.rss.widgets.SimpleWidget.java