You are not logged in.
Pages: 1
I am a Java noob, so please be patient with me.
After calling getContent, I still do not have the data :(
String data = null;
Object obj = null;
URL ebayURL = new URL("http", "www.google.com", 80, "index.html");
System.out.println("ebayURL.toString(): " + ebayURL.toString());
System.out.println("ebayURL.toExternalForm(): " + ebayURL.toString());
obj = ebayURL.getContent();
System.out.println("obj: " + obj.toString() );
this is the output I get
ebayURL.toString(): [url]http://www.google.com:80index.html[/url]
ebayURL.toExternalForm(): [url]http://www.google.com:80index.html[/url]
obj: [email protected]d9
what do I have to do to get the HTML text?
Offline
Disclaimer: I know absolutely NOTHING about Java... ;-)
However, just by looking at that printed URL of yours, I'm going
to say you want "/index.html" (or, simply "/" should suffice),
rather than "index.html"...
Offline
I tried your suggestion
ebayURL.toString(): http://www.google.com:80/index.html
ebayURL.toExternalForm(): http://www.google.com:80/index.html
obj: [email protected]786
anyone else here a java expert? does anyone else know of other forums where people may have more advice? Don't get me wrong, I like this forum, but I need the answer to this question soon!
Offline
Since you are calling getContent and storing the return into an Object type, the call to print is simply outputting it's (the Object class object ~ wow, that sounds confusing... lol) info... this is a simple Object's default behaviour...
Try casting the return from the getContent call to a String type... and storing it in a String object... then do your printout...
Same idea for other data types... i.e. if you are pulling down more complex types of data... cast... then display... in some cases, you may have to make your own (new) data types to handle the content...
Michael
"The only difference between me and a madman is that I'm not mad."
Salvador Dali (1904-1989)
Offline
String data = null;
Object obj = null;
URL ebayURL = new URL("http", "www.google.com", 80, "index.html");
System.out.println("ebayURL.toString(): " + ebayURL.toString());
System.out.println("ebayURL.toExternalForm(): " + ebayURL.toString());
obj = ebayURL.getContent();
System.out.println("obj: " + obj.toString() );
for webpages, you don't use getContent(). getContent() is used for non text/html or text/plain type of contents from the internet.
instead, why don't you just use the openStream() method of URL class and then you can read from the InputStream object.
Offline
Pages: 1