This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Buffered Writer problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Buffered Writer problem" Watch "Buffered Writer problem" New topic
Author

Buffered Writer problem

sujay bawaskar
Greenhorn

Joined: Mar 19, 2009
Posts: 7
Hi
I am trying to write a file on unix in append mode with following code:

long ts=System.currentTimeMillis();
String filename="temp"+ts+".txt";
File file=new File(filename);
file.createNewFile();
FileWriter fw=new FileWriter(file,true);
BufferedWriter bw=new BufferedWriter(fw);
bw.write(excelString.toString()); //excelString is StringBuffer

//pseudo code
for loop{
//some code here for populating excelString
bw.write(excelString.toString());
}
bw.close();

This seems to work fine on MS windows xp but it is overwriting file when it runs on unix.
I am not getting where exactly is the problem. Is the java.io APIs have different behavioral constucts with unix?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Buffered Writer problem
 
Similar Threads
Not able to write the output to the file.
Doubt about IO package
File writing
Problem creating files from JSP
In Java program how to export data from database to text file