Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7578551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:27:34+00:00 2026-05-30T17:27:34+00:00

I am trying to read an RSS feed . I have tried many links

  • 0

I am trying to read an RSS feed. I have tried many links using the code below and succeeded, but when I try with that link above I get a FileNotFoundException. What could cause this, and how do I fix my code?

EfficientAdapter class:

package com.xmlparse;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class EfficientAdapter extends BaseAdapter 
{
    private Activity activity;
    private ArrayList<Post> data;
    private static LayoutInflater inflater = null;
    //public ImageLoader imageLoader;
    ViewHolder holder;

    EfficientAdapter(Activity a, ArrayList<Post> d) {
            activity = a;
            data = d;
            inflater = (LayoutInflater) activity
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //      imageLoader = new ImageLoader(activity.getApplicationContext());

    }

    @Override
    public int getCount() {
            return data.toArray().length;
    }

    @Override
    public Object getItem(int position) {
            return position;
    }

    @Override
    public long getItemId(int position) {
            return position;
    }

    public static class ViewHolder {
            public TextView label;
            public TextView addr;
            public ImageView image;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
            View vi = convertView;

            if (convertView == null) {
                    vi = inflater.inflate(R.layout.row, null);
                    holder = new ViewHolder();
                    holder.label = (TextView) vi.findViewById(R.id.title);
                    holder.addr = (TextView) vi.findViewById(R.id.details);
                    holder.image = (ImageView) vi.findViewById(R.id.thumb);
                    vi.setTag(holder);
            } else
                    holder = (ViewHolder) vi.getTag();

            holder.label.setText(data.get(position).getTitle());
    //      holder.addr.setText(data.get(position).getPubDate());
            holder.addr.setText(data.get(position).getDescription());
             imageLoader.DisplayImage((data.get(position).getThumbnail()), activity,
                            holder.image, 72, 72);
             URL url = null;
             try {
                    url = new URL((data.get(position).getThumbnail()));
            } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
            }
            InputStream content = null;
            try {
                    content = (InputStream)url.getContent();
            } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
            }
            Drawable d = Drawable.createFromStream(content , "src"); 
            Bitmap mIcon1 = null;
             try {
                     mIcon1 =
                            BitmapFactory.decodeStream(url.openConnection().getInputStream());
            } catch (IOException e) {
                    e.printStackTrace();
            }
            holder.image.setImageBitmap(Bitmap.createScaledBitmap(mIcon1, 72, 72, false));


            return vi;
     }

}

Post class:

package com.xmlparse;
public class Post {

    private String title;
    private String thumbnail;
    private String url;
    private String description;
    private String pubDate;

    public String getTitle() {
            return title;
    }

    public void setTitle(String title) {
            this.title = title;
    }

    public String getThumbnail() {
            return thumbnail;
    }

    public void setThumbnail(String thumbnail) {
            this.thumbnail = thumbnail;
    }

    public String getUrl() {
            return url;
    }

    public void setUrl(String url) {
            this.url = url;
    }

    public void setDescription(String description) {
            this.description = description;
    }

    public String getDescription() {
            return description;
    }

    public void setPubDate(String pubDate) {
            this.pubDate = pubDate;
    }

    public String getPubDate() {
            return pubDate;
    }

   }

xmlparsemain activity class:

package com.xmlparse;

import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class xmlparsemain extends Activity {
    /** Called when the activity is first created. */
    ListView lv1;
    ProgressDialog ShowProgress;
    public ArrayList<Post> PostList = new ArrayList<Post>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            lv1 = (ListView) findViewById(R.id.listView1);

            ShowProgress = ProgressDialog.show(xmlparsemain.this, "",
                            "Loading. Please wait...", true);
            new loadingTask().execute("http://screenrant.com/mobile/movie-reviews-feed.php");

            lv1.setOnItemClickListener(new OnItemClickListener() {
                    public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {

                            Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri
                                            .parse(PostList.get(position).getUrl()));
                            startActivity(intent);

                    }
            });

    }

    class loadingTask extends AsyncTask<String, Void, String> {

            protected String doInBackground(String... urls) {

                    SAXHelper sh = null;
                    try {
                            sh = new SAXHelper(urls[0]);
                    } catch (MalformedURLException e) {
                            e.printStackTrace();
                    }
                    sh.parseContent("");
                    return "";

            }

            protected void onPostExecute(String s) {
                    lv1.setAdapter(new EfficientAdapter(xmlparsemain.this, PostList));
                    ShowProgress.dismiss();

            }
    }

    class SAXHelper {
            public HashMap<String, String> userList = new HashMap<String, String>();
            private URL url2;

            public SAXHelper(String url1) throws MalformedURLException {
                    this.url2 = new URL(url1);
            }

            public RSSHandler parseContent(String parseContent) {
                    RSSHandler df = new RSSHandler();
                    try {

                            SAXParserFactory spf = SAXParserFactory.newInstance();
                            SAXParser sp = spf.newSAXParser();
                            XMLReader xr = sp.getXMLReader();
                            xr.setContentHandler(df);

                       /*     URLConnection con = url2.openConnection();
                            con.setConnectTimeout(20000);
                         InputSource   is = new InputSource(new InputStreamReader(con.getInputStream()));
                       xr.parse(is);*/
                            xr.parse(new InputSource(url2.openStream()));
                    } catch (Exception e) {
                            e.printStackTrace();
                    }
                    return df;
            }
    }

    class RSSHandler extends DefaultHandler {

            private Post currentPost = new Post();
            StringBuffer chars = new StringBuffer();

            @Override
            public void startElement(String uri, String localName, String qName,
                            Attributes atts) {

                    chars = new StringBuffer();
                    if (localName.equalsIgnoreCase("item")) {

                    }
            }

            @Override
            public void endElement(String uri, String localName, String qName)
                            throws SAXException {

                    if (localName.equalsIgnoreCase("title")
                                    && currentPost.getTitle() == null) {
                            currentPost.setTitle(chars.toString());

                    }
                    if (localName.equalsIgnoreCase("pubDate")
                                    && currentPost.getPubDate() == null) {
                            currentPost.setPubDate(chars.toString());

                    }
                    if (localName.equalsIgnoreCase("description")
                                    && currentPost.getDescription() == null) {
                            currentPost.setDescription(chars.toString());

                    }
                    if (localName.equalsIgnoreCase("thumbnail")
                                    && currentPost.getThumbnail() == null) {
                            currentPost.setThumbnail(chars.toString());

                    }
                    if (localName.equalsIgnoreCase("link")
                                    && currentPost.getUrl() == null) {
                            currentPost.setUrl(chars.toString());
                    }

                    if (localName.equalsIgnoreCase("item")) {
                            PostList.add(currentPost);
                            currentPost = new Post();
                    }

            }

            @Override
            public void characters(char ch[], int start, int length) {
                    chars.append(new String(ch, start, length));
            }

     }

}

My logcat report:

02-29 15:20:44.183: W/System.err(2470): java.io.FileNotFoundException: http://screenrant.com/mobile/movie-news-feed.php
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:27:35+00:00Added an answer on May 30, 2026 at 5:27 pm

    try using HTtpConnection instead of URLConnection, as follows:

    InputStream callWebErvice(String serviceURL){
            // http get client
                HttpClient client=new DefaultHttpClient();
                HttpGet getRequest=new HttpGet();
    
                try {
                    // construct a URI object
                    getRequest.setURI(new URI(serviceURL));
                } catch (URISyntaxException e) {
                    Log.e("URISyntaxException", e.toString());
                }
    
                // buffer reader to read the response
                BufferedReader in=null;
                // the service response
                HttpResponse response=null;
                try {
                    // execute the request
                    response = client.execute(getRequest);
                } catch (ClientProtocolException e) {
                    Log.e("ClientProtocolException", e.toString());
                } catch (IOException e) {
                    Log.e("IO exception", e.toString());
                }
                if(response!=null)
                    return response.getEntity().getContent();
                else
                    return null;
    
        }
    

    and change line xr.parse(new InputSource(url2.openStream()));

    to

    xr.parse(new InputSource(callWebErvice(url2)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find a library that can read a given RSS/Atom feed, and
Trying to read an RSS and select information using Linq but can't seem to
I am trying read rss feed of stack overflow using Linq to xml. I
I am trying to read an external rss feed using a xAgent, I seem
I'm trying to read an RSS feed from Flickr but it has some nodes
I'm trying to read an rss feed using powershell and I can't extract a
I'm trying to read and store an RSS feed in my database using this
I am trying to parse an RSS feed with feedparser. The below code snipped
I'm trying to use SimpleXML to read our News RSS feed but it's not
I am trying to read a simple Twitpic rss feed but not having much

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.