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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:42:24+00:00 2026-05-13T14:42:24+00:00

First of all, my target here is to read from a URL, parse it,

  • 0

First of all, my target here is to read from a URL, parse it, and take information from it and give it to another method sendMessage which then sends it to an IRC client. I haven’t been doing java long so I’m adapting things I code I find on the internet. The below methods work when they are declared in their own class file, and run by passing the URL to the main method, but I can’t seem to get it to work either by calling the class from MyBot or declaring the methods in my MyBot file.

public static BufferedReader read(String url) throws Exception{
    return new BufferedReader(
        new InputStreamReader(
            new URL(url).openStream()));}

public static String WebURL (String[] args) throws Exception{
    BufferedReader reader = read(args[0]);
    String line = reader.readLine();
    String newURL = new String();

    while (line != null) {
    if (line.contains("<meta ")) {
            String predef = new String(line.split("<meta content='")[1]);
            //line.indexOf finds where to take up till, substring takes from beginning until there
            String def = new String(predef.substring(0, (predef.indexOf("' name="))));
            newURL = def;
        }
    else {
        newURL = "No definition available";
    }
    line = reader.readLine(); }
    return newURL;

    }

Now in the main I have the following:

if (message.startsWith("!def ")) {
        String[] myArray = new String[2];   
        myArray[0] = message;
        MyBot myURL = new MyBot();
        myURL.WebURL(myArray);
        sendMessage(channel, myURL);
    }

The error I get when trying to compile is the following:

 MyBot.java:62: cannot find symbol
symbol : sendMessage(java.lang.String,java.lang.String)
cannot be applied to (java.lang.String,MyBot)
sendMessage(channel,myURL);
^

So it seems to be saying that MyURL isn't a String, but the method return type is String.. so I'm obviously something here (probably I'm using return wrong?)

Very grateful of anyone's help, and if there is a better way than this of doing what I want I would be happy to hear that too 🙂 Thanks!

EDIT: To the first few answers whichtell me to pass myURL.WebURL(myArray) to sendMessage, I already this but got the following error which confused me more:

unreported exception java.lang.Exception; must be caught or declared to be throw
I understand this is because WebURL throws an exception but I don't know how to declare/catch this when I'm declaring a String..

  • 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-13T14:42:24+00:00Added an answer on May 13, 2026 at 2:42 pm

    myUrl is a type MyBot from the line:

    MyBot myURL = new MyBot();
    

    If you change the next lines from:

    myURL.WebURL(myArray);
    sendMessage(channel, myURL);
    

    to:

    String actualUrl = myURL.WebURL(myArray);
    sendMessage(channel, actualUrl);
    

    it should work

    EDIT: If you’re throwing an exception from myURL.WebUrl(myArray), enclose it in a try/catch block:

    String actualUrl = null;
    try {
        actualUrl = myURL.WebURL(myArray);
    } catch (Exception e) {
        actualUrl = "Something default";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, let's define a few tables: Users table will store information about
I'll explain myself, here is my scenario: Compile my target Do a first optimization
first of all here is my situation. I am programming an intranet application using
First of all sorry guys for posting the question here. The support forum seems
Im trying to first grab all the links from a page, when get the
First of all, I know how to build a Java application. But I have
First of all, I don't need a textual comparison so Beyond Compare doesn't do
First of all, I'm fairly sure snapping to grid is fairly easy, however I've
First of all: I am not an experienced ClearCase user, but I have lots
First of all (in case this is important) I'm using ActiveState's Perl (v5.8.7 built

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.