Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File I/O prior to Java 1.5

 
Sandra Bachan
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Chapter 6 of Sierra/Bates, I understand that prior to Java 5 PrintWriter didn't have constructors that took either a String or a File.

However, when I compile the code with:

% javac -source 1.4 Writer.java

It works. Please see code below and advise. From what I understand, it should NOT work:



 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are confusing the Java compiler with the Java API. The -source 1.4 switch tells the compiler to compile the code as if the compiler version was 1.4 (no generics, etc). The Java API is still the whatever is in the jar file.
 
Sandra Bachan
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the clarification!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic