[Advanced-java] How Can I Prevent when file in use??
Bikash Paul
bikashpaul_2001 at yahoo.com
Mon May 19 06:48:57 2003
Hi all friends,
I am facing problem with my uploading software it is a
automatic process of uploading only user copy the file
in hot folder of my software and software takes the
file one by one automatically and start uploading on
destination and it also shows the name and size of
file on text area of my swing my interface for user
information which file it is uploading.Now my problem
is when user copy the file from network computer in
that folder in between copy my software shows the file
name and size(which is incomplete size)on text area of
swing interface and after completion of copy it shows
the complete size and name of same file again.But it
couldn't read the file coz sharing violation.My
software checks its folder for file every after 30
seconds and I have done it by therads.I want to
prevent my software so that it can't take the file
name and size in between copy of that file means it
can't show name and size of incomplete file.Can any
one plz guide me how i can do that.Iam pasting those
portion of my codes:-
Upload.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try{
myThread = new Thread ()
{
public void run () {
while (true) {
checkForFilesToUpload ("d:\\DTMS\\Input\\");
try{
this.sleep (30000);
}catch(Exception nx){} }
}
};
myThread.start();
}catch(Exception exp) {
Error("Error : " + exp.toString());
}
}
});
//checkForFilesToUpload method(those portion only)
for (int k = 0; k < fileList1.size(); k++) {
filen = (File)fileList1.get(k);
filename=filen.getName();
filesize=filen.length();
filesizeinKB=filesize/1024;
textArea1a.append(i+"."+" "+" "+filename+"\n");
textArea1b.append(filesizeinKB+" KB"+"\n");
i=i+1;
}
Regards
Bikash
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com