I have a class SpellingSuggestor
, whose constructor has the signature
public SpellingSuggestor(File file) throws IOException { // something }
I want to invoke its constructor from another class. The code goes something like this
public class NLPApplications
public static void main(String[] args) {
String w= "randomword";
URL url = getClass().getResource("big.txt");
File file = new File(url.getPath());
System.out.println((new SpellingSuggestor(file)).correct(w));
}
}
But the above shows error in the URL url..
line saying
- URL cannot be resolved to a type.
- cannot make a static reference to the non-static method getClass() from the type Object.
What is going wrong ?
I looked at this question How to pass a text file as a argument?. I am not comfortable with handling files in Java and so this question.