datamosh
datamosh

Reputation: 65

Getting text off a website and set it as a string in Java

I'm trying to get some text from a website and set it as a String in Java.

I have little to no experience with web connections in Java and would appreciate some help.

Here's what I've got so far:

static String wgetURL = "http://www.realmofthemadgod.com/version.txt";
static Document Version;
static String displayLink = "http://www.realmofthemadgod.com/AGCLoader" + Version + ".swf";

public static void main(String[] args) throws IOException{
    Version = Jsoup.connect(wgetURL).get();
    System.out.println(Version);
    JOptionPane.showMessageDialog(null, Version, "RotMG SWF Finder", JOptionPane.DEFAULT_OPTION);
}

I'm trying to use Jsoup but I keep getting startup errors (it has issues when starting up).

Upvotes: 0

Views: 63

Answers (1)

Jean Logeart
Jean Logeart

Reputation: 53819

Your problem is not Jsoup related.

You are trying to create a String with Version while Version is not defined.

Change your code to:

public static void main(String[] args) throws IOException{
    String url = "http://www.realmofthemadgod.com/version.txt"
    Document doc = Jsoup.connect(url).get();
    System.out.println(doc);
    // query doc using jsoup ...
}

Upvotes: 1

Related Questions