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]
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.557 / Virus Database: 349 - Release Date: 12/30/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.557 / Virus Database: 349 - Release Date: 12/30/2003
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]