forked from marceloverdijk/lesscss-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileResource.java
More file actions
49 lines (39 loc) · 1.06 KB
/
Copy pathFileResource.java
File metadata and controls
49 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.lesscss;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* File based implementation of {@link Resource}.
*
* @author Anton Pechinsky
*/
public class FileResource implements Resource {
private File file;
public FileResource(File file) {
if (file == null) {
throw new IllegalArgumentException("File must not be null!");
}
this.file = file;
}
public boolean exists() {
return file.exists();
}
public InputStream getInputStream() throws IOException {
return new FileInputStream(file);
}
public long lastModified() {
return file.lastModified();
}
public Resource createRelative(String relativePath) {
File relativeFile = new File(file.getParentFile(), relativePath);
return new FileResource(relativeFile);
}
@Override
public String toString() {
return file.getAbsolutePath();
}
public String getName() {
return file.getAbsolutePath();
}
}