A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
Scanner
dolly shah
Ranch Hand
Joined: Jun 18, 2007
Posts: 383
posted
Oct 08, 2007 07:06:00
0
Source-Whizlabs.
It is given that the file(a.txt) is already exist. Why we need new File(a.txt) in constructor parameter. Can anyone please explain?
Scanner sc=new Scanner (new File(a.txt));
SCJP-1.5<br />SCWCD-1.4
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35257
7
posted
Oct 08, 2007 08:31:00
0
Because "new File(...)" does not create a file - it creates a
File
object. You need a
File
object to work with existing files as well as new files.
Android apps
–
ImageJ plugins
–
Java web charts
dolly shah
Ranch Hand
Joined: Jun 18, 2007
Posts: 383
posted
Oct 08, 2007 09:59:00
0
Thanks Ulf.
I agree. Here's the link:
http://aspose.com/file-tools
subject: Scanner
Similar Threads
file creation
File Reading using J2ME
Best data storage method
File
Multitread synchronization
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter