0

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.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by new_2_java
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.