I have been getting there error:
error: no suitable constructor found for File(File)
File file = new File(testFile);
^
constructor File.File(String,int) is not applicable
(actual and formal argument lists differ in length)
constructor File.File(String,File) is not applicable
(actual and formal argument lists differ in length)
constructor File.File(String) is not applicable
(argument mismatch; File cannot be converted to String)
constructor File.File(String,String) is not applicable
(actual and formal argument lists differ in length)
constructor File.File(File,String) is not applicable
(actual and formal argument lists differ in length)
constructor File.File(URI) is not applicable
(argument mismatch; File cannot be converted to URI)
I do not understand what the error is telling me, could someone please explain? This is my code:
public ShortenWord( File testFile ) {
try {
File file = new File(testFile);
Scanner in = new Scanner(file);
List originalWords = new List();
List abbWords = new List();
while (in.hasNextLine())
{
String line = in.nextLine();
String[] parts = line.split(",");
String originalWord = parts[0];
String abbWord = parts[1];
}
}
catch (FileNotFoundException e)
{
System.out.println(e);
}
}
Any help on how to fix this error would be greatly appreciated. As I don't have a clue :)
File constructor expect File pathname as String for single parameter. You shouldn't pass another file object at File constructor.
File file = new File("somefilename.txt");
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments