home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 June / INTERNET92.ISO / pc / software / windows / building / visual_dhtml / visualdhtmlwin9x_nt.exe / PFMovr.___ (.txt) < prev    next >
Encoding:
Java Class File  |  2001-10-19  |  1.3 KB  |  66 lines

  1. import java.io.DataInputStream;
  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6.  
  7. class PFMovr {
  8.    public static void copyFile(File var0, File var1) throws IOException {
  9.       FileInputStream var2 = null;
  10.       FileOutputStream var3 = null;
  11.       if (!var0.equals(var1)) {
  12.          try {
  13.             if (var0.exists() && var0.isFile()) {
  14.                if (!var0.canRead()) {
  15.                   System.out.println("Can't read source file.");
  16.                   return;
  17.                }
  18.  
  19.                if (var1.exists()) {
  20.                   if (!var1.isFile()) {
  21.                      return;
  22.                   }
  23.  
  24.                   new DataInputStream(System.in);
  25.                   if (!var1.canWrite()) {
  26.                      return;
  27.                   }
  28.                }
  29.  
  30.                var2 = new FileInputStream(var0);
  31.                var3 = new FileOutputStream(var1);
  32.                byte[] var4 = new byte[1024];
  33.  
  34.                while(true) {
  35.                   int var5 = var2.read(var4);
  36.                   if (var5 == -1) {
  37.                      return;
  38.                   }
  39.  
  40.                   var3.write(var4, 0, var5);
  41.                }
  42.             }
  43.  
  44.             System.out.println("Source file doesn't exist!");
  45.             System.out.println("Source file: " + var0.getAbsolutePath());
  46.          } finally {
  47.             if (var2 != null) {
  48.                try {
  49.                   var2.close();
  50.                } catch (IOException var22) {
  51.                }
  52.             }
  53.  
  54.             if (var3 != null) {
  55.                try {
  56.                   var3.close();
  57.                } catch (IOException var21) {
  58.                }
  59.             }
  60.  
  61.          }
  62.  
  63.       }
  64.    }
  65. }
  66.