KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > java > io > FileImpl


1 package alt.java.io;
2
3 import java.io.FileFilter JavaDoc;
4 import java.io.FilenameFilter JavaDoc;
5 import java.io.IOException JavaDoc;
6 import java.net.MalformedURLException JavaDoc;
7 import java.net.URL JavaDoc;
8
9 public class FileImpl implements File {
10     private final java.io.File JavaDoc file;
11
12     public FileImpl(java.io.File JavaDoc file) {
13         this.file = file;
14     }
15
16     public FileImpl(String JavaDoc fileName) {
17         this.file = new java.io.File JavaDoc(fileName);
18     }
19
20     public String JavaDoc getName() {
21         return file.getName();
22     }
23
24     public String JavaDoc getParent() {
25         return file.getParent();
26     }
27
28     public File getParentFile() {
29         return new FileImpl(file.getParentFile());
30     }
31
32     public String JavaDoc getPath() {
33         return file.getPath();
34     }
35
36     public boolean isAbsolute() {
37         return file.isAbsolute();
38     }
39
40     public String JavaDoc getAbsolutePath() {
41         return file.getAbsolutePath();
42     }
43
44     public File getAbsoluteFile() {
45         return new FileImpl(file.getAbsoluteFile());
46     }
47
48     public String JavaDoc getCanonicalPath() throws IOException JavaDoc {
49         return file.getCanonicalPath();
50     }
51
52     public File getCanonicalFile() throws IOException JavaDoc {
53         return new FileImpl(file.getCanonicalFile());
54     }
55
56     public URL JavaDoc toURL() throws MalformedURLException JavaDoc {
57         return file.toURL();
58     }
59
60     public boolean canRead() {
61         return file.canRead();
62     }
63
64     public boolean canWrite() {
65         return file.canWrite();
66     }
67
68     public boolean exists() {
69         return file.exists();
70     }
71
72     public boolean isDirectory() {
73         return file.isDirectory();
74     }
75
76     public boolean isFile() {
77         return file.isFile();
78     }
79
80     public boolean isHidden() {
81         return file.isHidden();
82     }
83
84     public long lastModified() {
85         return file.lastModified();
86     }
87
88     public long length() {
89         return file.length();
90     }
91
92     public boolean createNewFile() throws IOException JavaDoc {
93         return file.createNewFile();
94     }
95
96     public boolean delete() {
97         return file.delete();
98     }
99
100     public void deleteOnExit() {
101         file.deleteOnExit();
102     }
103
104     public String JavaDoc[] list() {
105         return file.list();
106     }
107
108     public String JavaDoc[] list(FilenameFilter JavaDoc filter) {
109         return file.list();
110     }
111
112     public File[] listFiles() {
113         return toAltFileArray(file.listFiles());
114     }
115
116     public File[] listFiles(FilenameFilter JavaDoc filter) {
117         return toAltFileArray(file.listFiles(filter));
118     }
119
120     public File[] listFiles(FileFilter JavaDoc filter) {
121         return toAltFileArray(file.listFiles(filter));
122     }
123
124     private final File[] toAltFileArray(java.io.File JavaDoc[] files) {
125         if(files==null)return null;
126
127         File[] altFiles = new File[files.length];
128
129         for(int i = 0; i < files.length; i++) {
130             altFiles[i] = new FileImpl(files[i]);
131         }
132
133         return altFiles;
134     }
135
136     public boolean mkdir() {
137         return file.mkdir();
138     }
139
140     public boolean mkdirs() {
141         return file.mkdirs();
142     }
143
144     public File createTempFile(String JavaDoc prefix, String JavaDoc suffix, File directory) throws IOException JavaDoc {
145         return new FileImpl(java.io.File.createTempFile(prefix, suffix,
146             directory.getRealFile()));
147     }
148
149     public File createTempFile(String JavaDoc prefix, String JavaDoc suffix) throws IOException JavaDoc {
150         return new FileImpl(java.io.File.createTempFile(prefix, suffix));
151     }
152
153     public File[] listRoots() {
154         return toAltFileArray(java.io.File.listRoots());
155     }
156
157     public boolean renameTo(File dest) {
158         return file.renameTo(dest.getRealFile());
159     }
160
161     public boolean setLastModified(long time) {
162         return file.setLastModified(time);
163     }
164
165     public boolean setReadOnly() {
166         return file.setReadOnly();
167     }
168
169     public int compareTo(File pathname) {
170         return file.compareTo(pathname.getRealFile());
171     }
172
173     public int compareTo(Object JavaDoc o) {
174         return file.compareTo(o);
175     }
176
177     public java.io.File JavaDoc getRealFile() {
178         return file;
179     }
180 }
181
Popular Tags