|
URLList
Jan 20, 2002 13:59:07 GMT -5
Post by 1.8T on Jan 20, 2002 13:59:07 GMT -5
The only problem is that when you need to list the elements, you have to somehow split the url and title from the element and print it out one after the other. How do you suppose you do that?! i didn't do it yet. but i'm planning to make an object with (url, title) like that., and when u store it in the vector u'll have url and title inone element., and u wouldn't hafta split it later,. but i'm not sure wut it returns when i type .elementAt does it return the object?> i have no idea how to use vectors.,
|
|
|
URLList
Jan 20, 2002 14:03:10 GMT -5
Post by Observer on Jan 20, 2002 14:03:10 GMT -5
One way to do it for list is to store the url and title like this:
url"\n"title
So when you print that it will write url title
on the screen on two different lines. However, there could possibly be problems later on with that. Right now I'm completely stumped on how I'm going to distinguish between the URL and title for searches/look ups.
Not of importance but my monitor just had a power surge or something and so I had to take it off and attach this really old one that sucks. This couldn't have happened at a worst time.
|
|
|
URLList
Jan 20, 2002 14:37:22 GMT -5
Post by 1.8T on Jan 20, 2002 14:37:22 GMT -5
One way to do it for list is to store the url and title like this: url"\n"title So when you print that it will write url title on the screen on two different lines. However, there could possibly be problems later on with that. Right now I'm completely stumped on how I'm going to distinguish between the URL and title for searches/look ups. for title searches and look ups if u did it the \n way i would suggest using indexOf to find where \n is then split up url and title.,
|
|
|
URLList
Jan 20, 2002 17:13:55 GMT -5
Post by Brutal_Chicken on Jan 20, 2002 17:13:55 GMT -5
Can someone tell me why this isn't legal?
int x = Integer.parseInt(command.substring(5));
Where command is the string for input.
|
|
bAh
Junior Member
Posts: 23
|
URLList
Jan 20, 2002 18:00:46 GMT -5
Post by bAh on Jan 20, 2002 18:00:46 GMT -5
Can someone tell me why this isn't legal? int x = Integer.parseInt(command.substring(5)); Where command is the string for input. I believe it's the substring(5) that's haunting you in ur case, the substring should be : int x = Integer.parseInt(command.substring(START LOCATION, END LOCATION); 2 parameters instead of one
|
|
|
URLList
Jan 20, 2002 18:25:35 GMT -5
Post by Brutal_Chicken on Jan 20, 2002 18:25:35 GMT -5
Did that, still nothing. Bah, this is the only thing keeping me from finishing up! I've already written the swap method inside URLList it's just the damned A1Driver is mixing it up. Even my URLListTester agrees that the swap method is ok.
The only thing left is to take user input.
Oh man.... I just figured it out!!!
Look at it closely... it starts at index 5 where it should be index 4!!! Sonuvabitch! 3 friggin' hours for one lil' number! That's it, I'm getting drunk. I'll see you guys tomorrow at the torture rack.
|
|
bAh
Junior Member
Posts: 23
|
URLList
Jan 20, 2002 18:38:08 GMT -5
Post by bAh on Jan 20, 2002 18:38:08 GMT -5
Did that, still nothing. Bah, this is the only thing keeping me from finishing up! I've already written the swap method inside URLList it's just the damned A1Driver is mixing it up. Even my URLListTester agrees that the swap method is ok. The only thing left is to take user input. Oh man.... I just figured it out!!! Look at it closely... it starts at index 5 where it should be index 4!!! Sonuvabitch! 3 friggin' hours for one lil' number! That's it, I'm getting drunk. I'll see you guys tomorrow at the torture rack. just wanna know.. what error msg does it give you first? can't compile or runtime errors?
|
|
|
URLList
Jan 20, 2002 22:38:30 GMT -5
Post by Brutal_Chicken on Jan 20, 2002 22:38:30 GMT -5
It compiled correctly, the runtime error was that I was telling Java to search for a letter AFTER it appeared. A small number change and I was done.
|
|
|
URLList
Jan 20, 2002 22:55:22 GMT -5
Post by 1.8T on Jan 20, 2002 22:55:22 GMT -5
ok. i've just about had it iwth this assignment ARGHH.,
ok. for my list command i had to return my Vector to another class to print,.
so returned the whole thing as one big string with \n between everything but i want a better way than this.,., any suggestions or hints as an alternative to this?
|
|
|
URLList
Jan 20, 2002 23:52:41 GMT -5
Post by Observer on Jan 20, 2002 23:52:41 GMT -5
I used a for loop in the A1Driver to print the list.
How about any ideas on doing ANY of the write and load commands...
|
|
|
URLList
Jan 21, 2002 0:05:21 GMT -5
Post by 1.8T on Jan 21, 2002 0:05:21 GMT -5
sorry but load and write commands are too long to explain.,, um i'll go brief about it load : i just used indexOf in a loop and went line by line lookng for url and title and extracted it like that., and ran a method of URLList that adds it to the Vector.,., i call this method inside the loop., so line by line it adds to the vector element by element
write: if u know how to do list command, just modify that return it as a big string and use PrintStream to write to file
now for my question.,., if i load an html file just say 1.html its list of urls and titles are stored in my vector then i type write 2.html and write those urls and titles onto a new html file then i type list to list wuts in my vector.., but my vectors still contain the urls and title from 1.html
so my output after i type list is repeated cuz i stored 1.html's info onto 2.html and when i list it lists out both the 1.html and 2.html information of the vector., does anyone know if that's wut they want? or should i clear my vector after i write a new file??
|
|
bAh
Junior Member
Posts: 23
|
URLList
Jan 21, 2002 0:10:31 GMT -5
Post by bAh on Jan 21, 2002 0:10:31 GMT -5
I used a for loop in the A1Driver to print the list. How about any ideas on doing ANY of the write and load commands... for load... what i did is to store each line into a String variable and after that i searched a specific part of an address by using indexOf (hint: gee... ever wonders why some words appear in URLs all the time?) searching for the URL title is the same idea.. with a little twist of course, before you store those lines into the vector/arraylist u need to make sure that some lines are addresses instead of other HTML tags
|
|
|
URLList
Jan 22, 2002 11:51:41 GMT -5
Post by Yingster on Jan 22, 2002 11:51:41 GMT -5
now for my question.,., if i load an html file just say 1.html its list of urls and titles are stored in my vector then i type write 2.html and write those urls and titles onto a new html file then i type list to list wuts in my vector.., but my vectors still contain the urls and title from 1.html so my output after i type list is repeated cuz i stored 1.html's info onto 2.html and when i list it lists out both the 1.html and 2.html information of the vector., does anyone know if that's wut they want? or should i clear my vector after i write a new file?? after u write to 2.html ur vector should not contain any info thats in ur 2.html ur vector should only contain the urls from 1.html
|
|
|
URLList
Jan 22, 2002 13:16:33 GMT -5
Post by Goku on Jan 22, 2002 13:16:33 GMT -5
Why do i get this error Error : Can't make static reference to method void addURL(java.lang.String) in class URLList. A1Driver.java line 34 URLList.addURL(op); for this method call: URLList.addURL(op); My method inside URLList is addURL(String s) ...List.addElement(s); ... and i get that error?
|
|
|
URLList
Jan 22, 2002 14:02:04 GMT -5
Post by 1.8T on Jan 22, 2002 14:02:04 GMT -5
Why do i get this error Error : Can't make static reference to method void addURL(java.lang.String) in class URLList. A1Driver.java line 34 URLList.addURL(op); for this method call: URLList.addURL(op); My method inside URLList is addURL(String s) ...List.addElement(s); ... and i get that error? did u cast it as (String) and 10005 posts ? ahhh the perks of being admin ;D EDIT: actually wut i just said didn't solve your problem.,., but i didn't use static at all inthis assignment and also ., i didn't use static anywhere., and aslo., all my variables for this assignment are local.,., i have no instance variables., is this bad programming style??
|
|