| 1 |
|
| 2 |
|
| 3 |
package com.nwalsh.saxon; |
| 4 |
|
| 5 |
import java.io.File; |
| 6 |
import java.lang.NullPointerException; |
| 7 |
|
| 8 |
public class Website { |
| 9 |
public Website() { |
| 10 |
} |
| 11 |
|
| 12 |
public static boolean exists(String filename) { |
| 13 |
try { |
| 14 |
File file = new File(filename); |
| 15 |
return file.exists(); |
| 16 |
} catch (NullPointerException npe) { |
| 17 |
return false; |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
public static boolean needsUpdate(String srcFilename, |
| 22 |
String targetFilename) { |
| 23 |
File srcFile; |
| 24 |
File targetFile; |
| 25 |
|
| 26 |
try { |
| 27 |
targetFile = new File(targetFilename); |
| 28 |
} catch (NullPointerException npe) { |
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
try { |
| 33 |
srcFile = new File(srcFilename); |
| 34 |
} catch (NullPointerException npe) { |
| 35 |
return false; |
| 36 |
} |
| 37 |
|
| 38 |
if (!srcFile.exists()) { |
| 39 |
return false; |
| 40 |
} |
| 41 |
|
| 42 |
if (!targetFile.exists()) { |
| 43 |
return true; |
| 44 |
} |
| 45 |
|
| 46 |
return (srcFile.lastModified() > targetFile.lastModified()); |
| 47 |
} |
| 48 |
} |