This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
import java.io.*; public class fileOutput { public static void main(String args[]) { String fn = "d:/new/net.txt"; File f1 = new File(fn); try { f1.createNewFile(); FileOutputStream fStream = new FileOutputStream(f1, true); } catch(Exception e) { System.out.println(e); } } } why cant I run this code in jdk 1.3??? but the same code with different variables are wirtten in IVOR HOrton book. Waiting For Reply Muddassir Sayeed
John Fairbairn
Ranch Hand
Joined: May 30, 2002
Posts: 55
posted
0
I don't believe the code will compile. Here you are passing a File object and boolean as parameters to the constructor for the FileOutputStream object. This is not valid. You can pass a String (pathname to file) and a boolean if you want. The javadoc for FileOutputStream shows the valid ways to construct this object.
Muddassir Sayeed
Greenhorn
Joined: Jul 08, 2001
Posts: 7
posted
0
Thanks For the reply . yes you are right. This code will run on JDK 1.4 which allow File object as argument, but here i am writing the code from the book IVOR Horton which is confusing me. String filename = "myFile.txt"; File aFile = new File(filename); try { aFile.createNewFile(); FileOutputStream file1 = new FileOutputStream(aFile, true); } catch(IOException e) { System.out.println(e); }
This is the code which is written in the ivor Horton's book by name Beginning JAVA 2 (JDK 1.3 Edition). please answer me. hope your answers will help me and make be able to understand this code. May be this is the error of the book Muddassir Sayeed [ July 11, 2002: Message edited by: Muddassir Sayeed ]