01: /*
02: * TransferDirectory.java
03: *
04: * Created on July 9, 2002, 11:15 AM
05: */
06:
07: package com.sun.portal.ffj.util;
08:
09: import java.io.File;
10: import java.io.FileInputStream;
11: import java.io.FileOutputStream;
12: import java.io.IOException;
13:
14: import org.openide.TopManager;
15: import org.openide.ErrorManager;
16:
17: /**
18: *
19: * @author yabob
20: */
21: public abstract class Transfer {
22: public abstract void transfer(File wsroot, String wsdir, File psfs);
23:
24: // actual file copy.
25:
26: protected void copy(File from, File to) {
27: try {
28: to.getParentFile().mkdirs();
29:
30: FileInputStream is = new FileInputStream(from);
31: FileOutputStream os = new FileOutputStream(to);
32: byte buf[] = new byte[8000];
33:
34: for (;;) {
35: int len;
36: if ((len = is.read(buf)) < 0) {
37: break;
38: }
39: os.write(buf, 0, len);
40: }
41:
42: os.flush();
43: os.close();
44: } catch (IOException iex) {
45: TopManager.getDefault().getErrorManager().notify(
46: ErrorManager.USER, iex);
47: }
48: }
49: }
|