views:

31

answers:

2

Hello, I use this code

for(int i = 0; i < citylink.length; i++) {
    body=pF.fetchpage(citylink[i][1]);
    // It's for taking the url from the table citylink
    // and returns the source of this url!

I have also declared it in my pagefetcher.java class like this:

public String fetchPage(String url) {
    try {
        url = URIUtil.encodeQuery(url);
    } catch (URIException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

but when I compile it it says that the method fetchpage(String) is undefined for the type PageFetcher and I can't run my problem! I don't know what to do.

A: 

Your method needs to return a string. The method is declared as a public String, but fails to return the value you want (url)

EricR
i'm totally confused
kate
public String fetchPage(String citylink) { try { citylink = URIUtil.encodeQuery(citylink); } catch (URIException e) { // TODO Auto-generated catch block e.printStackTrace(); } GetMethod get; get = new GetMethod(citylink); get.setFollowRedirects(true);i changed my fetchpage.java like this but it still doesn't work :(
kate
A: 

You declare your code as

public String fetchPage(String url) {

And call it as

body=pF.fetchpage(citylink[i][1]);

Java is case sensitive: you should rename either of them to match eachother.

Pindatjuh
and how i should call it?
kate
`pF.fetchPage` or `public String fetchpage`: one of them.
Pindatjuh
this excact code worked for another project i don't think that this is the problem and i declare a new instance of pagefetcher PageFetcher pF = new PageFetcher(); so i think that what's in the fetchpage is wrong as a declaration!but i don't know how t fix it
kate