01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package com.opensymphony.webwork.util.classloader.readers;
17:
18: import org.apache.commons.io.FileUtils;
19:
20: import java.io.File;
21:
22: /**
23: * @author tcurdt
24: */
25: public final class FileResourceReader implements ResourceReader {
26:
27: private final File base;
28:
29: public FileResourceReader(final File pBase) {
30: base = pBase;
31: }
32:
33: public boolean isAvailable(String filename) {
34: return new File(base, filename).exists();
35: }
36:
37: public char[] getContent(final String fileName) {
38: try {
39: return FileUtils.readFileToString(new File(base, fileName),
40: "UTF-8").toCharArray();
41: } catch (Exception e) {
42: }
43: return null;
44: }
45: }
|