Reputation: 673
Guys i'm just wandering what is the difference between these lines
Scanner file = new Scanner(new FileReader(new File(filePath)));
Scanner file = new Scanner(new File(filePath));
Scanner file = new Scanner(new FileReader(filePath));
is their any kind of instance when you will use them? or their all the same?
Upvotes: 1
Views: 629
Reputation: 43867
They're all identical. The File
constructors are for convenience. Sometimes you will get other Readers
(not from a File) or need to construct the FileReader
yourself (in order to specify an encoding) in which case the Reader
constructor is important.
Upvotes: 1