• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileReader or Scanner?  RSS feed

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've head of people using this "FileReader", isn't it just as easy to just use Scanner?

like so:



Thanks,

Justin Fox
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends what JRE's you want to support. Scanner was only introduced in Java 1.5.
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh ok.

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

Justin Fox
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cool, that makes sense.

Thanks for the info,

Justin Fox
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!