I have a question about Java and file input / output. For a special job, I have to move a file (to be accurate), while it has been opened. Imagine the following scenario:
An Excel file is opened by a user and used periodically, the file is manually saved by the user. Now I want to write a Java program that reads the file and transfers it to the socket every 30 seconds. No problem yet My question: What if the user saves the document in the exact moment then my program wants to read the file, can it be the cause of any problem?
I do not know what it means, but IM using a buffer inputstream to read the file.
My question: What if the user saves the document in the exact time then my program file Wants to read Could this be the cause of any problem?
Yes.
One or more of the following may be based on your platform, and the way Excel file is saved
If Excel Using locking, the program trying to read either excel or program can get an error by saying that the file is in use.
If the excel does a rewrite in place and does not lock the file, then the program is trying to read the file, it can see a sorted Excel file is.
If Excel writes a new file and renames it, which is trying to read the file, it can see the situation where the file is not apparently present. is.
This can work.
In short, the need to read the program is very defensive ...
It is not known that this is the case, But use it to read a bufferInputTream file.
I think it is irrelevant
Comments
Post a Comment