[Advanced-java] Auto selection of file from folder during uploading??

Bikash Paul bikashpaul_2001 at yahoo.com
Fri May 9 13:56:01 2003


Hi all friends,

Iam facing with one problem I am developing one
uploading software for that i have used swing and
servlet.Now my problem is i want to give auto
selection of file from one folder means user just copy
the files from any computer on network and paste it in
predefind folder.And when they click on upload button
it should start uploading of file one by one and after
completion of uploading it move that file into another
folder one by one.Now my software doing it perfectly
but if user copy and paste any file in that predifined
folder from network computer during uploading then
they have to click upload button again after
completion of first queue of files(for example if user
first copy 10 files and start uploading and inbetween
uploading of that 10 files if user copy another 10
files from network computer then they have to click on
upload button again after completion of uploading of
first 10 files).But my user requirement is they want
to click on upload button once only at the time of
starting my application and my application
automatically select the file one by one from folder
and send it to destination.Means if they copy the file
from network machine inbetween uploading or any other
user from network send file in that folder then my
application should select those file automatically and
start uploading means they don't want to click on
upload button again.Can any one plz guide how I can
slove this problem.Below r my codes:-

Upload.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
suspendflag=true;
Resume.setEnabled(false);
Suspend.setEnabled(false);
dest=frame.m_txtURL.getText();
File ff=new File("d:\\DTMS\\Upload");
File[] files = ff.listFiles();
fileList = new Vector();
if(files == null)
{
textArea.append("There is no file");
return;
}
else
{
for (int j = 0 ; j< files.length ; j++)
{
fileList.add(files[j]);
}
}
java.util.Collections.sort(fileList, new
FileComp());//sorting by size
new Thread(new Runnable() {
public void run(){
for (int k = 0; k < fileList.size(); k++)//loop for
queue {
File fname = (File)fileList.get(k);
String str=fname.getName();
log("Destination:" +" "+ dest);
log("Uploading Progress\nPlease Wait....");
result=doPost(fname,dest);//method for read file &
send to servlet
String str2="Transfer apparently failed.";
String str3=result;
if(str2.equals(str3)){
Error(result);
}
else if(suspendflag==true){
File newfile =new File("d:\\DTMS\\Archives\\"+str);
fname.renameTo(newfile);
log("File" +" "+ str+" "+"Upload Completed !");
}
else if(suspendflag==false){
Error("** Transfer Suspended**");
}
}
}
}).start();
}catch(Exception exp)
{
Error("Error : " + exp.toString());
}
}
});

Regards
Bikash


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com