1 package org.kuali.common.util.file;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.net.URI;
6
7
8
9
10 public final class CanonicalFile extends File {
11
12 private static final long serialVersionUID = -8366640724070158688L;
13
14
15
16
17 public CanonicalFile(File parent, String child) {
18 this(new File(parent, child));
19 }
20
21
22
23
24 public CanonicalFile(String parent, String child) {
25 this(new File(parent, child));
26 }
27
28
29
30
31 public CanonicalFile(URI uri) {
32 this(new File(uri));
33 }
34
35
36
37
38 public CanonicalFile(String path) {
39 this(new File(path));
40 }
41
42
43
44
45 public CanonicalFile(File file) {
46 super(getCanonicalPath(file));
47 }
48
49
50
51
52 public static final CanonicalFile cwd() {
53 return new CanonicalFile(".");
54 }
55
56 protected static String getCanonicalPath(File file) {
57 try {
58 return file.getCanonicalPath();
59 } catch (IOException e) {
60 throw new IllegalStateException("unexpected io error", e);
61 }
62 }
63
64 }