Hi all,

I would like to know what is the difference between OutputStream and BufferedWriter objects? Can I use them interchangeabally?

Reason is because I created a job that has to run every, lets say, 5 minutes. The problem is that when I run my java program manually from the OS command prompt, like

$java MyProgram

then it works fine and it creates the file, using BufferedWriter. But when I schedual the Job to use my program, then it doesn't work. It doesn't use BufferedWriter.

Anyone can help me out, what do I need to do to make it work??

Thanks and regards.

BufferedWriter is used for writing to the underlying file stream which you have opened. The files in consideration are created by the FileWriter object you use inside the constructor of the BufferedWriter class.

From docs:

Whether or not a file is available or may be created depends upon the underlying platform. Some platforms, in particular, allow a file to be opened for writing by only one FileWriter (or other file-writing object) at a time. In such situations the constructors in this class will fail if the file involved is already open.

Maybe posting the code in consideration would shed some light on the situation.

BufferedWriter is used for writing to the underlying file stream which you have opened. The files in consideration are created by the FileWriter object you use inside the constructor of the BufferedWriter class.

From docs:


Maybe posting the code in consideration would shed some light on the situation.

Infact, I used RandocAccessFile object, and surprisingly, it started working.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.