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 8625203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:43:27+00:00 2026-06-12T07:43:27+00:00

I am new in android. I have built an project. I have a class

  • 0

I am new in android. I have built an project.

I have a class that check if the url exist or not like this:

public class connect {
Boolean checkServer() throws IOException
{
    Boolean check = false;
    HttpURLConnection connection = null;
    try {
        URL url = new URL("www.google.com");
        connection = (HttpURLConnection) url.openConnection();
        connection.connect();
        connection.getInputStream();
                    // do something with the input stream here
        check = true;
    } catch (MalformedURLException e1) {
        e1.printStackTrace();
        check = false;
    }
    finally {
        if(null != connection) { connection.disconnect(); }
    }
    return check;
}

}

And I want to run it as single file in eclipse.

How can I do this?

thank anyway

  • 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-12T07:43:28+00:00Added an answer on June 12, 2026 at 7:43 am

    You can write a Junit class or in a simple way, write a new class with public static void main() method or with in the same class and in main() method you should create an object of the class and launch the main() method

    public class ConnectDemo {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
    
            Connect c = new Connect();
    
            if(c.checkServer())
                System.out.println("Check Server Successful");
            else 
                System.out.println("Check Server not Successful");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed some reusable android component which is basically a class . This
edit: This is an Android project. My problem arose when I added a new
I'm new to Android, trying to launch the project, which is being built and
n00b here (first Android project). I have been given a custom video codec that
I have dug out an old android project that I was working on a
I have read this link :Open an image in Android's built-in Gallery app programmatically
I am using ANT to compile an Android app that I have built. It
While creating a new android project in eclipse 3.5, i have selected Android 2.1
hi to all i am new to android i have to send my different
I am a bit new with android but I have some java experience. So

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.