No Suitable constructor found for File(file)

user3307598

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 :)

Masudul

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JsonMappingException: No suitable constructor found

From Dev

No Suitable Constructor Found (Java)

From Dev

Java no suitable constructor found

From Dev

No suitable constructor found for JsonObjectRequest

From Dev

No suitable Constructor Found

From Dev

No suitable constructor found for java

From Dev

No suitable constructor found for type GeoJsonPoint

From Dev

CsvParser "No suitable constructor found for type"

From Dev

No Suitable Constructor Found for Student (no arguments)

From Dev

No Suitable constructor found for File(file)

From Dev

No suitable constructor found for type GeoJsonPoint

From Dev

JsonMappingException: No suitable constructor found for type

From Dev

JsonMappingException: No suitable constructor found for type -- for an external object

From Dev

Chrome driver with Selenium : "no suitable constructor found for RemoteWebDriver"

From Dev

Suitable constructor for type not found (View Component)

From Dev

No suitable constructor found for type when we use an Enum - Jackson JSON

From Dev

No suitable constructor found error occuring inside extended subclass Constructors

From Dev

"no suitable method found for add(java.lang.String)"in arraylist constructor?

From Dev

Android no suitable constructor found for HeaderItem(int,String,<null>)

From Dev

How do I fix a Java:26: error: No suitable constructor found

From Dev

No suitable constructor found for type when we use an Enum - Jackson JSON

From Dev

No suitable constructor found for TreeMap with Comparator<Map.Entry

From Dev

JavaFX : Retrieving Image from server, no suitable constructor found

From Dev

no suitable constructor found for JsonObjectRequest error when using volley

From Dev

Class has no suitable copy constructor, no binary operator '=' found,

From Dev

OSMdroid - error: no suitable constructor found for Overlay(no arguments) constructor Overlay.Overlay(Context) is not applicable

From Dev

ActionBarDrawerToggle No Suitable Constructor Drawable

From Dev

Missing suitable constructor

From Dev

Jersey: No suitable constructor found for type [simple type, class Thing]: can not instantiate from JSON object

Related Related

  1. 1

    JsonMappingException: No suitable constructor found

  2. 2

    No Suitable Constructor Found (Java)

  3. 3

    Java no suitable constructor found

  4. 4

    No suitable constructor found for JsonObjectRequest

  5. 5

    No suitable Constructor Found

  6. 6

    No suitable constructor found for java

  7. 7

    No suitable constructor found for type GeoJsonPoint

  8. 8

    CsvParser "No suitable constructor found for type"

  9. 9

    No Suitable Constructor Found for Student (no arguments)

  10. 10

    No Suitable constructor found for File(file)

  11. 11

    No suitable constructor found for type GeoJsonPoint

  12. 12

    JsonMappingException: No suitable constructor found for type

  13. 13

    JsonMappingException: No suitable constructor found for type -- for an external object

  14. 14

    Chrome driver with Selenium : "no suitable constructor found for RemoteWebDriver"

  15. 15

    Suitable constructor for type not found (View Component)

  16. 16

    No suitable constructor found for type when we use an Enum - Jackson JSON

  17. 17

    No suitable constructor found error occuring inside extended subclass Constructors

  18. 18

    "no suitable method found for add(java.lang.String)"in arraylist constructor?

  19. 19

    Android no suitable constructor found for HeaderItem(int,String,<null>)

  20. 20

    How do I fix a Java:26: error: No suitable constructor found

  21. 21

    No suitable constructor found for type when we use an Enum - Jackson JSON

  22. 22

    No suitable constructor found for TreeMap with Comparator<Map.Entry

  23. 23

    JavaFX : Retrieving Image from server, no suitable constructor found

  24. 24

    no suitable constructor found for JsonObjectRequest error when using volley

  25. 25

    Class has no suitable copy constructor, no binary operator '=' found,

  26. 26

    OSMdroid - error: no suitable constructor found for Overlay(no arguments) constructor Overlay.Overlay(Context) is not applicable

  27. 27

    ActionBarDrawerToggle No Suitable Constructor Drawable

  28. 28

    Missing suitable constructor

  29. 29

    Jersey: No suitable constructor found for type [simple type, class Thing]: can not instantiate from JSON object

HotTag

Archive