This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes FileReader or Scanner? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "FileReader or Scanner?" Watch "FileReader or Scanner?" New topic
Author

FileReader or Scanner?

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
I've head of people using this "FileReader", isn't it just as easy to just use Scanner?

like so:



Thanks,

Justin Fox


You down with OOP? Yeah you know me!
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3720
    
  16
Depends what JRE's you want to support. Scanner was only introduced in Java 1.5.


Joanne
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Yeah, generally I think Scanner is better for just about everything, but it simply didn't exist in earlier JDKs - that's why people use FileReader.


"I'm not back." - Bill Harding, Twister
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
oh ok.

why would you use 1.5? I mean, version 6 is out now...

Justin Fox
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42356
    
  64
Well, Scanner was in 1.5, so the proper question would be "who wants to use 1.4?" Reading through the posts here on JavaRanch, the answer is obviously "many people".

As to why someone would use Java 1.5, well, not all operating systems have a released version of Java 6 yet, OS X being the most prominent one.


Ping & DNS - my free Android networking tools app
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3720
    
  16
Also a lot of code was written when 1.4 was the latest JRE. Even if newer developments of this code are being written in 1.6, people are not going to want to rewrite existing, correctly functioning code just to use a different class.
[ April 04, 2008: Message edited by: Joanne Neal ]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
cool, that makes sense.

Thanks for the info,

Justin Fox
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileReader or Scanner?