[Advanced-java] Auto selection of file from folder during
uploading??
Uddipan Bagchi
uddipan.bagchi at wipro.com
Fri May 9 15:40:53 2003
I believe that the line -
File[] files = ff.listFiles();
- returns you a static list of files as of the moment the method was
executed. If you want to take cognizance of files that are added to the
directory after the method has been executed, then you need to
incorporate a loop that executes this method (and the subsequent block
of processing code) repeatedly till no change in number of files in the
directory is detected.
BTW, there's more than way of detecting if the directory contents have
changed. You could simply count the number of files and compare against
the past number, or build a FileFilter based on file's date, or ...a few
others.
Cheers.
- Uddipan.
Senior Consultant,
Solutions Consulting Group,
Wipro Technologies,
Kings Court,
185, Kings Road,
Reading - RG1 4EX
0118-9022324 (O)
881-224 (VOIP)
07905-799063 (M)
> -----Original Message-----
> From: advanced-java-bounces@lists.xcf.berkeley.edu
[mailto:advanced-java-
> bounces@lists.xcf.berkeley.edu] On Behalf Of Bikash Paul
> Sent: 09 May 2003 13:56
> To: advanced-java@lists.xcf.berkeley.edu
> Subject: [Advanced-java] Auto selection of file from folder during
uploading??
>
> 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
> _______________________________________________
> Advanced-java mailing list
> Advanced-java@lists.xcf.berkeley.edu
> http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro Limited is
'privileged' and 'confidential' and intended for use only by the individual
or entity to which it is addressed. You are notified that any use, copying
or dissemination of the information contained in the E-MAIL in any manner
whatsoever is strictly prohibited.
***************************************************************************