Hi Tom,

Thanks so much!

Which existing file would I insert this code (or would I have to create a new 
file then place this file in some Tomcat subdirectory??)  And are srcDir and 
dstDir arbitary folder names?

Thanks so much - I'm a newbie with this.

Kay


~Kayley~ 
----- Original Message ----- 
From: "Tom K" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
Sent: Thursday, April 01, 2004 4:40 PM
Subject: RE: redirecting uploaded files in tomcat5


> Kay,
> 
> What you need to do is copy or move the directories (on the same
> machine) e.g.
> 
> /**
>  * Copies all files under srcDir to dstDir, if dstDir does not exist, it
> * will be created.
> */
> 
>     public void copyDirectory(File srcDir, File dstDir) throws
> IOException {
>         if (srcDir.isDirectory()) {
>             if (!dstDir.exists()) {
>                 dstDir.mkdir();
>             }
>     
>             String[] children = srcDir.list();
>             for (int i=0; i<children.length; i++) {
>                 copyDirectory(new File(srcDir, children[i]),
>                                      new File(dstDir, children[i]));
>             }
>         } else {
>             copy(srcDir, dstDir);
>         }
>     }
> 
> // Copies src file to dst file.
>     // If the dst file does not exist, it is created
>     void copy(File src, File dst) throws IOException {
>         InputStream in = new FileInputStream(src);
>         OutputStream out = new FileOutputStream(dst);
>     
>         // Transfer bytes from in to out
>         byte[] buf = new byte[1024];
>         int len;
>         while ((len = in.read(buf)) > 0) {
>             out.write(buf, 0, len);
>         }
>         in.close();
>         out.close();
>     }
> 
> 
> Now if you have to copy a file to another computer, take a look at using
> an ftp client and redirecting it (using a 'put') to another computer.
> You may even look at using a native method via jni for doing your file
> transfer. Have a look here:
> http://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html
> 
> 
> 
> Regards,
> 
> Tom Kochanowicz
> Janitor II
> Nebraska Psychiatric Hospital
> 
> 
> 
> 
> 
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 01, 2004 3:24 PM
> To: Tomcat Users List
> Subject: redirecting uploaded files in tomcat5
> 
> Hi,
> 
> After I get files uploaded into the webapp folder of Tomcat5, how can I 
> redirect them to be located/copied/moved OUTSIDE of the Tomcat folders?
> (and 
> possibly send them to other machines)
> 
> Thanks,
> Kay
> 


----------------------------------------
This mail sent through www.mywaterloo.ca

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to