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.
The moose likes Java in General and the fly likes Appending to file | Error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Appending to file | Error" Watch "Appending to file | Error" New topic
Author

Appending to file | Error

Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 238
Hi everyone,
Iam writing a very simple code to append some contents to a file; the contents are character.But in eclpise it says : Constructor BufferedWriter(File,boolean) is undefined.

Here is the sample code:

File file = new File(System.getProperty("user.dir") + "\\Errors\\"
+ filename);

try {
// Create file if it does not exist
file.createNewFile();
} catch (IOException e) {
success = false;
}

//use buffering
Writer output = new BufferedWriter(new FileWriter(file, true));


Now this gives compilation errors saying construtor for BufferedWriter is undefined.Similarly it also sats Constructor for FileWriter is undefined.

This is a simple copy and paste program, which is shpwing these errors.

Can anyone site me where ia m going wrong ??

Saurabh


Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Manuel Moons
Ranch Hand

Joined: Mar 05, 2002
Posts: 229
It is not possible that this code gives the error that you stated above.

This code:

can not give this error:
Constructor BufferedWriter(File,boolean) is undefined.

You are not using a constructor for bufferedwriter using File and boolean parameter. You are using a constructor for FileWriter using File and boolean parameters. FileWriter does have this constructor but when you look at the javadoc for JDK 1.4 you can see that it is added in 1.4. So, your problem might be that you are not using JDK 1.4 but an earlier version.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Appending to file | Error
 
Similar Threads
Need help writing to a text file
BufferedReader help
BufferedWriter
Why are my output files blank?
Write somethin' out without overwriting