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

  • Home
  • SEARCH
  • 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 8915847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:05:09+00:00 2026-06-15T05:05:09+00:00

I am total noob at Android dev. I am still learning, and I am

  • 0

I am total noob at Android dev. I am still learning, and I am on very first step of my app dev.

I have this code working and it runs fine or regular Java, now I am trying to implement to Android OS.

In my code where it says TEST.openStream() I get Unhandled exception type IOException error.

 package com.zv.android;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.os.Bundle;

public class ZipActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        try {
            URL TEST = new URL("http://www.google.com/");
            BufferedReader in = new BufferedReader(new InputStreamReader(TEST.openStream()));

            String inputLine;
            int line=0;
            while ((inputLine = in.readLine()) != null){
                line++;
                       //System.out.println(line + "\t" + inputLine); 
            }
           // in.close();
        } catch(MalformedURLException e) {
            //Do something with the exception.
        }

    }
}
  • 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-06-15T05:05:11+00:00Added an answer on June 15, 2026 at 5:05 am

    Error message is simple: you need to catch the IOException, this because URL.openStream() is declared as

    public final InputStream openStream() throws IOException
    

    so by accepting the contract of the method you also accept the fact that you must handle this exception, this is how it works in Java. This is a checked exceptions, then it must be caught because this kind of exceptions represent situations that may arise and that your code must handle.

    To catch it just add another case in your try statement:

    try {
      ..
    catch (MalformedURLException e) {
      ..
    }
    catch (IOException e) {
      ..
    }
    

    Just as a final note: you don’t need to catch it when you call the openStream() method, you could state that the method that calls openStream() will forward the exception to the caller but in the end of the call chain you will have to catch it in any case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a total noob to android and really have very hard time understanding
Total noob here learning openGL and I don't have any code to post because
Total noob here. This is my first c# attempt, its a console application that
I am a total noob on this issue, and I wonder if I have
First of all I'm a total noob (as you might noticed) in Android environment.
I am evaluating moving some jQuery code to Backbone and have a total noob
I'm creating my first android app. It seems fairly simple. But I'm a total
Total noob here with javascript. I'm trying to alter a function. This is the
I'm a total noob when it comes to C but i found this curl
First timer here, and total noob when it comes to PHP and JavaScript. I

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.