Locking of files
Hi,
Can someone guide me how can we lock the files and then read it. I know we can do it using the FileLock and FileChannel. But I want to do it using FileReader as my file contains charecters and I think using FileReader will be much better than using FileInputStream.
Can a channel be obtained using FileReader?
Please let me know about this.
[370 byte] By [
Amana] at [2007-10-2 4:38:07]

The FileReader is actually a convenience class, and as such, can be rather inconvenient when you want to do something that isn't default behavior.
Try constructing an InputStreamReader on top of a FileInputStream. Then you get the character-reading behavior at the same time that you're exposing the input stream behavior you want to be able to deal with.
(Note that when you construct a new FileReader, it's constructing a FileInputStream, too. It's just not giving you an easy way to see it.)
--Dylan
Just an idea.
If a file is being read, it cannot be deleted by java or any windows app.
If you want to know if your file is in use in another part of your program just compare them to see if it's the same file, if it is, put your thead in to a loop with a wait() until the file no longer matches, then continue the thread. Sounds right to me.